Merge pull request #625 from MyIgel/docker

Docker: Decouple nginx and fpm builds
This commit is contained in:
msquare 2019-07-21 13:43:11 +02:00 committed by GitHub
commit 3fed76876c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 9 deletions

View File

@ -30,9 +30,17 @@ stages:
build-image.nginx: build-image.nginx:
<<: *docker_definition <<: *docker_definition
stage: build-frontend stage: build-frontend
artifacts:
name: "${CI_JOB_NAME}_${CI_JOB_ID}_assets"
expire_in: 1 day
paths:
- ./public/assets
script: script:
- docker build --pull -t "${TEST_IMAGE}-nginx" -f contrib/nginx/Dockerfile . - docker build --pull -t "${TEST_IMAGE}-nginx" -f contrib/nginx/Dockerfile .
- docker push "${TEST_IMAGE}-nginx" - docker push "${TEST_IMAGE}-nginx"
- instance=$(docker create "${TEST_IMAGE}-nginx")
- docker cp "${instance}:/var/www/public/assets" public/
- docker rm "${instance}"
build-image: build-image:
<<: *docker_definition <<: *docker_definition
@ -40,7 +48,7 @@ build-image:
script: script:
- apk -q add git - apk -q add git
- VERSION="$(git describe --abbrev=0 --tags)-${CI_COMMIT_REF_NAME}+${CI_PIPELINE_ID}.${CI_COMMIT_SHORT_SHA}" - VERSION="$(git describe --abbrev=0 --tags)-${CI_COMMIT_REF_NAME}+${CI_PIPELINE_ID}.${CI_COMMIT_SHORT_SHA}"
- docker build --pull --build-arg NGINX_IMAGE="${TEST_IMAGE}-nginx" --build-arg VERSION="${VERSION}" -t "${TEST_IMAGE}" -f contrib/Dockerfile . - docker build --pull --build-arg VERSION="${VERSION}" -t "${TEST_IMAGE}" -f contrib/Dockerfile .
- docker push "${TEST_IMAGE}" - docker push "${TEST_IMAGE}"
test: test:
@ -114,6 +122,7 @@ build-release-file:
- ./release/ - ./release/
script: script:
- rsync -vAax "${DOCROOT}" release/ - rsync -vAax "${DOCROOT}" release/
- rsync -vAax public/assets release/public/
deploy-staging: deploy-staging:
<<: *deploy_definition <<: *deploy_definition

View File

@ -98,7 +98,7 @@ vendor/bin/phpunit
### CI & Build Pipeline ### CI & Build Pipeline
The engelsystem can be tested and automatically deployed to a testing/staging/production environment. The engelsystem can be tested and automatically deployed to a testing/staging/production environment.
This functionality requires a [GitLab](https://about.gitlab.com/) server with a running docker minion. This functionality requires a [GitLab](https://about.gitlab.com/) server with a working docker runner.
To use the deployment features the following secret variables need to be defined (if undefined the step will be skipped): To use the deployment features the following secret variables need to be defined (if undefined the step will be skipped):
```bash ```bash

View File

@ -1,15 +1,9 @@
# Setup
ARG NGINX_IMAGE=engelsystem-nginx:latest
# composer install # composer install
FROM composer AS composer FROM composer AS composer
COPY ./ /app/ COPY ./ /app/
RUN composer --no-ansi install --no-dev --ignore-platform-reqs RUN composer --no-ansi install --no-dev --ignore-platform-reqs
RUN composer --no-ansi dump-autoload --optimize RUN composer --no-ansi dump-autoload --optimize
# Use frontend container for assets
FROM ${NGINX_IMAGE} AS frontend
# Intermediate container for less layers # Intermediate container for less layers
FROM alpine as data FROM alpine as data
COPY bin/ /app/bin COPY bin/ /app/bin
@ -18,7 +12,6 @@ COPY db/ /app/db
COPY import/ /app/import COPY import/ /app/import
COPY includes/ /app/includes COPY includes/ /app/includes
COPY public/ /app/public COPY public/ /app/public
COPY --from=frontend /var/www/public/assets/ /app/public/assets
COPY resources/lang /app/resources/lang COPY resources/lang /app/resources/lang
COPY resources/views /app/resources/views COPY resources/views /app/resources/views
COPY src/ /app/src COPY src/ /app/src