Skip to content

Commit 0255cd3

Browse files
committed
✨ reduce docker size
1 parent 1508b55 commit 0255cd3

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

.dockerignore

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
.git/
2-
.github/
3-
bin/run-in-docker.sh
4-
bin/run-tests-in-docker.sh
5-
tests/
6-
vendor/
7-
phpunit-tests/
1+
# Ignore everything to act as an allow list
2+
*
3+
4+
# Include application files
5+
!src/
6+
!composer.json
7+
!composer.lock
8+
!main.php
9+
!bin/run.sh

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ FROM composer:latest AS builder
33
WORKDIR /opt/representer
44
COPY . /opt/representer
55

6-
RUN /usr/bin/composer install --no-dev --no-interaction --no-progress --no-scripts --optimize-autoloader --working-dir=/opt/representer
6+
RUN /usr/bin/composer install \
7+
--no-dev \
8+
--no-interaction \
9+
--no-progress \
10+
--no-scripts \
11+
--classmap-authoritative \
12+
--working-dir=/opt/representer
713

814
FROM php:8.1-cli-alpine
915

bin/run-tests-in-docker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ docker run \
2020
--rm \
2121
--network none \
2222
--read-only \
23+
--mount type=bind,source="${PWD}/bin/run-tests.sh",destination=/opt/representer/bin/run-tests.sh \
2324
--mount type=bind,source="${PWD}/tests",destination=/opt/representer/tests \
2425
--mount type=tmpfs,destination=/tmp \
2526
--workdir /opt/representer \

0 commit comments

Comments
 (0)