Skip to content

Reduce docker image size (and build time) #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
uses: "actions/checkout@v2"

- name: "Docker Build"
run: "docker build ."
run: "DOCKER_BUILDKIT=1 docker build ."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUILDKIT FTW 💪

32 changes: 10 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM composer:2 AS composer

FROM ubuntu:20.04
FROM php:8.0-alpine

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

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

WORKDIR /app

RUN apt update \
&& apt install -y software-properties-common \
&& add-apt-repository -y ppa:ondrej/php \
&& apt install -y \
git \
gnupg \
libzip-dev \
zip \
php8.0-cli \
php8.0-curl \
php8.0-mbstring \
php8.0-readline \
php8.0-xml \
php8.0-zip \
&& apt clean

ADD composer.json /app/composer.json
ADD composer.lock /app/composer.lock
RUN apk add --no-cache git gnupg libzip \
&& apk add --no-cache --virtual .build-deps libzip-dev \
&& docker-php-ext-install zip \
&& apk del .build-deps

COPY composer.* /app/

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

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

RUN composer install -a --no-dev
RUN composer dump-autoload -a --no-dev

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