diff options
author | VirtualTam <virtualtam@flibidi.net> | 2018-02-14 23:13:05 +0100 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2018-02-14 23:13:05 +0100 |
commit | 3c51135f9a2029989ec74809ce531fa4aa521fa7 (patch) | |
tree | 0ab4e7c8d777f81bde62ee5389ecfe42dc24f220 /docker/alpine | |
parent | 8b48e36594394e367cbb33c7ad1a679ea57c374d (diff) | |
download | Shaarli-3c51135f9a2029989ec74809ce531fa4aa521fa7.tar.gz Shaarli-3c51135f9a2029989ec74809ce531fa4aa521fa7.tar.zst Shaarli-3c51135f9a2029989ec74809ce531fa4aa521fa7.zip |
docker: introduce multi-stage image build (master, latest)
Relates to https://github.com/shaarli/Shaarli/issues/755
Relates to https://github.com/shaarli/Shaarli/pull/1072
See:
- https://docs.docker.com/develop/develop-images/multistage-build/
- https://hub.docker.com/r/library/composer/
- https://github.com/composer/docker
- https://github.com/docker-library/docs/tree/master/composer
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'docker/alpine')
-rw-r--r-- | docker/alpine/Dockerfile.latest | 26 | ||||
-rw-r--r-- | docker/alpine/Dockerfile.master | 26 |
2 files changed, 29 insertions, 23 deletions
diff --git a/docker/alpine/Dockerfile.latest b/docker/alpine/Dockerfile.latest index dd4a173c..e9015c13 100644 --- a/docker/alpine/Dockerfile.latest +++ b/docker/alpine/Dockerfile.latest | |||
@@ -1,9 +1,19 @@ | |||
1 | # Stage 1: | ||
2 | # - Get Shaarli sources | ||
3 | # - Resolve PHP dependencies with Composer | ||
4 | FROM composer:latest as composer | ||
5 | RUN curl -L https://github.com/shaarli/Shaarli/archive/latest.tar.gz | tar xzf - \ | ||
6 | && mv Shaarli-latest shaarli \ | ||
7 | && cd shaarli \ | ||
8 | && composer --prefer-dist --no-dev install | ||
9 | |||
10 | # Stage 2: | ||
11 | # - Shaarli image | ||
1 | FROM alpine:3.6 | 12 | FROM alpine:3.6 |
2 | MAINTAINER Shaarli Community | 13 | LABEL maintainer="Shaarli Community" |
3 | 14 | ||
4 | RUN apk --update --no-cache add \ | 15 | RUN apk --update --no-cache add \ |
5 | ca-certificates \ | 16 | ca-certificates \ |
6 | curl \ | ||
7 | nginx \ | 17 | nginx \ |
8 | php7 \ | 18 | php7 \ |
9 | php7-ctype \ | 19 | php7-ctype \ |
@@ -15,7 +25,6 @@ RUN apk --update --no-cache add \ | |||
15 | php7-json \ | 25 | php7-json \ |
16 | php7-mbstring \ | 26 | php7-mbstring \ |
17 | php7-openssl \ | 27 | php7-openssl \ |
18 | php7-phar \ | ||
19 | php7-session \ | 28 | php7-session \ |
20 | php7-xml \ | 29 | php7-xml \ |
21 | php7-zlib \ | 30 | php7-zlib \ |
@@ -25,22 +34,15 @@ COPY nginx.conf /etc/nginx/nginx.conf | |||
25 | COPY php-fpm.conf /etc/php7/php-fpm.conf | 34 | COPY php-fpm.conf /etc/php7/php-fpm.conf |
26 | COPY services.d /etc/services.d | 35 | COPY services.d /etc/services.d |
27 | 36 | ||
28 | RUN curl -sS https://getcomposer.org/installer | php7 -- --install-dir=/usr/local/bin --filename=composer \ | 37 | RUN rm -rf /etc/php7/php-fpm.d/www.conf \ |
29 | && rm -rf /etc/php7/php-fpm.d/www.conf \ | ||
30 | && sed -i 's/post_max_size.*/post_max_size = 10M/' /etc/php7/php.ini \ | 38 | && sed -i 's/post_max_size.*/post_max_size = 10M/' /etc/php7/php.ini \ |
31 | && sed -i 's/upload_max_filesize.*/upload_max_filesize = 10M/' /etc/php7/php.ini | 39 | && sed -i 's/upload_max_filesize.*/upload_max_filesize = 10M/' /etc/php7/php.ini |
32 | 40 | ||
33 | 41 | ||
34 | WORKDIR /var/www | 42 | WORKDIR /var/www |
35 | RUN curl -L https://github.com/shaarli/Shaarli/archive/latest.tar.gz | tar xzf - \ | 43 | COPY --from=composer /app/shaarli shaarli |
36 | && mv Shaarli-latest shaarli \ | ||
37 | && cd shaarli \ | ||
38 | && composer --prefer-dist --no-dev install \ | ||
39 | && rm -rf ~/.composer \ | ||
40 | && chown -R nginx:nginx . | ||
41 | 44 | ||
42 | VOLUME /var/www/shaarli/data | 45 | VOLUME /var/www/shaarli/data |
43 | |||
44 | EXPOSE 80 | 46 | EXPOSE 80 |
45 | 47 | ||
46 | ENTRYPOINT ["/bin/s6-svscan", "/etc/services.d"] | 48 | ENTRYPOINT ["/bin/s6-svscan", "/etc/services.d"] |
diff --git a/docker/alpine/Dockerfile.master b/docker/alpine/Dockerfile.master index 58f7c6e7..9cb4dec4 100644 --- a/docker/alpine/Dockerfile.master +++ b/docker/alpine/Dockerfile.master | |||
@@ -1,9 +1,19 @@ | |||
1 | # Stage 1: | ||
2 | # - Get Shaarli sources | ||
3 | # - Resolve PHP dependencies with Composer | ||
4 | FROM composer:latest as composer | ||
5 | RUN curl -L https://github.com/shaarli/Shaarli/archive/master.tar.gz | tar xzf - \ | ||
6 | && mv Shaarli-master shaarli \ | ||
7 | && cd shaarli \ | ||
8 | && composer --prefer-dist --no-dev install | ||
9 | |||
10 | # Stage 2: | ||
11 | # - Shaarli image | ||
1 | FROM alpine:3.6 | 12 | FROM alpine:3.6 |
2 | MAINTAINER Shaarli Community | 13 | LABEL maintainer="Shaarli Community" |
3 | 14 | ||
4 | RUN apk --update --no-cache add \ | 15 | RUN apk --update --no-cache add \ |
5 | ca-certificates \ | 16 | ca-certificates \ |
6 | curl \ | ||
7 | nginx \ | 17 | nginx \ |
8 | php7 \ | 18 | php7 \ |
9 | php7-ctype \ | 19 | php7-ctype \ |
@@ -15,7 +25,6 @@ RUN apk --update --no-cache add \ | |||
15 | php7-json \ | 25 | php7-json \ |
16 | php7-mbstring \ | 26 | php7-mbstring \ |
17 | php7-openssl \ | 27 | php7-openssl \ |
18 | php7-phar \ | ||
19 | php7-session \ | 28 | php7-session \ |
20 | php7-xml \ | 29 | php7-xml \ |
21 | php7-zlib \ | 30 | php7-zlib \ |
@@ -25,20 +34,15 @@ COPY nginx.conf /etc/nginx/nginx.conf | |||
25 | COPY php-fpm.conf /etc/php7/php-fpm.conf | 34 | COPY php-fpm.conf /etc/php7/php-fpm.conf |
26 | COPY services.d /etc/services.d | 35 | COPY services.d /etc/services.d |
27 | 36 | ||
28 | RUN curl -sS https://getcomposer.org/installer | php7 -- --install-dir=/usr/local/bin --filename=composer \ | 37 | RUN rm -rf /etc/php7/php-fpm.d/www.conf \ |
29 | && rm -rf /etc/php7/php-fpm.d/www.conf \ | ||
30 | && sed -i 's/post_max_size.*/post_max_size = 10M/' /etc/php7/php.ini \ | 38 | && sed -i 's/post_max_size.*/post_max_size = 10M/' /etc/php7/php.ini \ |
31 | && sed -i 's/upload_max_filesize.*/upload_max_filesize = 10M/' /etc/php7/php.ini | 39 | && sed -i 's/upload_max_filesize.*/upload_max_filesize = 10M/' /etc/php7/php.ini |
32 | 40 | ||
33 | 41 | ||
34 | WORKDIR /var/www | 42 | WORKDIR /var/www |
35 | RUN curl -L https://github.com/shaarli/Shaarli/archive/master.tar.gz | tar xzf - \ | 43 | COPY --from=composer /app/shaarli shaarli |
36 | && mv Shaarli-master shaarli \ | ||
37 | && cd shaarli \ | ||
38 | && composer --prefer-dist --no-dev install \ | ||
39 | && rm -rf ~/.composer \ | ||
40 | && chown -R nginx:nginx . | ||
41 | 44 | ||
45 | RUN chown -R nginx:nginx . | ||
42 | VOLUME /var/www/shaarli/data | 46 | VOLUME /var/www/shaarli/data |
43 | 47 | ||
44 | EXPOSE 80 | 48 | EXPOSE 80 |