use multi-stage build

This commit is contained in:
Daniel Wolf 2022-04-20 17:06:13 -04:00
parent dd21b2d3fd
commit c1b5bae86a
Signed by: nephatrine
GPG Key ID: 59D70EC2E4AAB4D0
2 changed files with 40 additions and 24 deletions

View File

@ -9,19 +9,37 @@ platform:
steps:
- name: build
environment:
PDR_USER:
from_secret: docker-user-pdr
PDR_PASS:
from_secret: docker-pass-pdr
commands:
- docker build -t pdr.nephatrine.net/nephatrine/nginx-h5ai:cached --target builder .
- docker build -t pdr.nephatrine.net/nephatrine/nginx-h5ai:latest .
- HOME=/mnt/config/home docker push pdr.nephatrine.net/nephatrine/nginx-h5ai:latest
- docker login -p "$PDR_PASS" -u "$PDR_USER" pdr.nephatrine.net
- docker push pdr.nephatrine.net/nephatrine/nginx-h5ai:latest
- docker logout pdr.nephatrine.net
- name: publish
environment:
DOCKER_USER:
from_secret: docker-user
DOCKER_PASS:
from_secret: docker-pass
commands:
- docker tag pdr.nephatrine.net/nephatrine/nginx-h5ai:latest nephatrine/nginx-h5ai:latest
- HOME=/mnt/config/home docker push nephatrine/nginx-h5ai:latest
- docker rmi pdr.nephatrine.net/nephatrine/nginx-h5ai:latest
- docker login -p "$DOCKER_PASS" -u "$DOCKER_USER"
- docker push -a nephatrine/nginx-h5ai
- docker logout
depends_on:
- build
---
kind: pipeline
name: after
name: notify
steps:
- name: notify
- name: notify-status
image: appleboy/drone-discord
failure: ignore
settings:
@ -43,6 +61,6 @@ trigger:
---
kind: signature
hmac: c1a0be4377b47332d7e041007b00acd6af46154477676330dcd5ac8e0a85c823
hmac: d7774cd61d67081b28130ce74c567ec5045e030e95dd5df70f810ef3d9ce5039
...

View File

@ -1,24 +1,22 @@
FROM nephatrine/nginx-php:latest
FROM pdr.nephatrine.net/nephatrine/alpine-builder:latest AS builder
ARG H5AI_VERSION=0.31.0
RUN git -C /usr/src clone -b "$H5AI_VERSION" --single-branch --depth=1 https://github.com/glubsy/h5ai.git
RUN echo "====== COMPILE H5AI ======" \
&& cd /usr/src/h5ai \
&& npm install && npm run build \
&& mkdir -p /var/www/html/ \
&& unzip build/*.zip -d /var/www/html/
FROM pdr.nephatrine.net/nephatrine/nginx-php:latest
LABEL maintainer="Daniel Wolf <nephatrine@gmail.com>"
RUN echo "====== INSTALL TOOLS ======" \
&& apk add --no-cache \
ffmpeg \
imagemagick \
zip \
&& apk add --no-cache ffmpeg imagemagick zip \
&& sed -i 's~/mnt/config/www/~/mnt/config/www/:/mnt/media/~g' /etc/php/php-fpm.d/www.conf \
&& sed -i 's~index.html~index.html /_h5ai/public/index.php~g' /etc/nginx/nginx.conf
ARG H5AI_VERSION=0.31.0
RUN echo "====== COMPILE H5AI ======" \
&& apk add --no-cache --virtual .build-h5ai \
git \
npm \
&& git -C /usr/src clone -b "$H5AI_VERSION" --single-branch --depth=1 https://github.com/glubsy/h5ai.git && cd /usr/src/h5ai \
&& npm install && npm run build \
&& unzip build/*.zip -d /var/www/html/ \
&& mkdir -p /mnt/media \
&& cd /usr/src && rm -rf /usr/src/* \
&& apk del --purge .build-h5ai
&& sed -i 's~index.html~index.html /_h5ai/public/index.php~g' /etc/nginx/nginx.conf \
&& mkdir -p /mnt/media
COPY --from=builder /var/www/html/ /var/www/html/
COPY override /