Skip to content

Commit e1f0863

Browse files
authored
Merge pull request #115 from lcobucci/reduce-image-size
Reduce docker image size (and build time)
2 parents 14df145 + 144704b commit e1f0863

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
uses: "actions/checkout@v2"
1919

2020
- name: "Docker Build"
21-
run: "docker build ."
21+
run: "DOCKER_BUILDKIT=1 docker build ."

Dockerfile

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM composer:2 AS composer
22

3-
FROM ubuntu:20.04
3+
FROM php:8.0-alpine
44

55
COPY --from=composer /usr/bin/composer /usr/bin/composer
66

@@ -15,33 +15,21 @@ LABEL "maintainer"="https://github.com/laminas/technical-steering-committee/"
1515

1616
WORKDIR /app
1717

18-
RUN apt update \
19-
&& apt install -y software-properties-common \
20-
&& add-apt-repository -y ppa:ondrej/php \
21-
&& apt install -y \
22-
git \
23-
gnupg \
24-
libzip-dev \
25-
zip \
26-
php8.0-cli \
27-
php8.0-curl \
28-
php8.0-mbstring \
29-
php8.0-readline \
30-
php8.0-xml \
31-
php8.0-zip \
32-
&& apt clean
33-
34-
ADD composer.json /app/composer.json
35-
ADD composer.lock /app/composer.lock
18+
RUN apk add --no-cache git gnupg libzip \
19+
&& apk add --no-cache --virtual .build-deps libzip-dev \
20+
&& docker-php-ext-install zip \
21+
&& apk del .build-deps
22+
23+
COPY composer.* /app/
3624

3725
RUN COMPOSER_CACHE_DIR=/dev/null composer install --no-dev --no-autoloader
3826

3927
# @TODO https://github.com/laminas/automatic-releases/issues/8 we skip `.git` for now, as it isn't available in the build environment
4028
# @TODO https://github.com/laminas/automatic-releases/issues/9 we skip `.git` for now, as it isn't available in the build environment
4129
#ADD .git /app/.git
42-
ADD bin /app/bin
43-
ADD src /app/src
30+
COPY bin /app/bin/
31+
COPY src /app/src/
4432

45-
RUN composer install -a --no-dev
33+
RUN composer dump-autoload -a --no-dev
4634

4735
ENTRYPOINT ["/app/bin/console.php"]

0 commit comments

Comments
 (0)