Skip to content

Commit 0fe2eb2

Browse files
authored
Merge pull request #155 from os2display/feature/DISPLAY-986_build_separate_images
DISPLAY-986: Setup separate image builds for itkdev and os2display
2 parents e6ff92b + dd1dc0b commit 0fe2eb2

35 files changed

+504
-17
lines changed

.github/workflows/github_build_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
docker compose run --rm phpfpm composer clear-cache
2626
rm -rf infrastructure
2727
28-
- name: Make artefacts dir
28+
- name: Make assets dir
2929
run: |
3030
mkdir -p ../assets
3131
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
on:
3+
push:
4+
branches:
5+
- 'develop'
6+
7+
# This Action builds to itkdev/* using ./infrastructure/itkdev/*
8+
name: ITK Dev - Build docker image (develop)
9+
10+
jobs:
11+
docker:
12+
runs-on: ubuntu-latest
13+
env:
14+
APP_VERSION: develop
15+
COMPOSER_ALLOW_SUPERUSER: 1
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
20+
- name: Login to DockerHub
21+
uses: docker/login-action@v2
22+
with:
23+
username: ${{ secrets.DOCKERHUB_USER }}
24+
password: ${{ secrets.DOCKERHUB_TOKEN }}
25+
26+
# Build api
27+
- name: Docker meta (API)
28+
id: meta-api
29+
uses: docker/metadata-action@v4
30+
with:
31+
images: itkdev/os2display-api-service
32+
33+
- name: Build and push (API)
34+
uses: docker/build-push-action@v4
35+
with:
36+
context: ./infrastructure/itkdev/display-api-service/
37+
file: ./infrastructure/itkdev/display-api-service/Dockerfile
38+
build-args: |
39+
VERSION=${{ env.APP_VERSION }}
40+
push: true
41+
tags: ${{ steps.meta-api.outputs.tags }}
42+
labels: ${{ steps.meta-api.outputs.labels }}
43+
44+
# Build nginx (depends on api build)
45+
- name: Docker meta (Nginx)
46+
id: meta-nginx
47+
uses: docker/metadata-action@v4
48+
with:
49+
images: itkdev/os2display-api-service-nginx
50+
51+
- name: Build and push (Nginx)
52+
uses: docker/build-push-action@v4
53+
with:
54+
context: ./infrastructure/itkdev/nginx/
55+
file: ./infrastructure/itkdev/nginx/Dockerfile
56+
build-args: |
57+
APP_VERSION=${{ env.APP_VERSION }}
58+
push: true
59+
tags: ${{ steps.meta-nginx.outputs.tags }}
60+
labels: ${{ steps.meta-nginx.outputs.labels }}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
7+
# This Action builds to itkdev/* using ./infrastructure/itkdev/*
8+
name: ITK Dev - Build docker image (tag)
9+
10+
jobs:
11+
docker:
12+
runs-on: ubuntu-latest
13+
env:
14+
COMPOSER_ALLOW_SUPERUSER: 1
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Login to DockerHub
20+
uses: docker/login-action@v2
21+
with:
22+
username: ${{ secrets.DOCKERHUB_USER }}
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
25+
# Build api
26+
- name: Docker meta (API)
27+
id: meta-api
28+
uses: docker/metadata-action@v4
29+
with:
30+
images: itkdev/os2display-api-service
31+
32+
- name: Build and push (API)
33+
uses: docker/build-push-action@v4
34+
with:
35+
context: ./infrastructure/itkdev/display-api-service/
36+
file: ./infrastructure/itkdev/display-api-service/Dockerfile
37+
build-args: |
38+
APP_VERSION=${{ github.ref }}
39+
push: true
40+
tags: ${{ steps.meta-api.outputs.tags }}
41+
labels: ${{ steps.meta-api.outputs.labels }}
42+
43+
# Build nginx (depends on api build)
44+
- name: Docker meta (Nginx)
45+
id: meta-nginx
46+
uses: docker/metadata-action@v4
47+
with:
48+
images: itkdev/os2display-api-service-nginx
49+
50+
- name: Get the tag
51+
id: get_tag
52+
run: echo ::set-output name=git_tag::$(echo $GITHUB_REF_NAME)
53+
54+
- name: Build and push (Nginx)
55+
uses: docker/build-push-action@v4
56+
with:
57+
context: ./infrastructure/itkdev/nginx/
58+
file: ./infrastructure/itkdev/nginx/Dockerfile
59+
build-args: |
60+
APP_VERSION=${{ steps.get_tag.outputs.git_tag }}
61+
push: true
62+
tags: ${{ steps.meta-nginx.outputs.tags }}
63+
labels: ${{ steps.meta-nginx.outputs.labels }}

.github/workflows/docker_build_develop.yml renamed to .github/workflows/os2display_docker_build_develop.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on:
33
push:
44
branches:
55
- 'develop'
6-
name: Build docker image (develop)
6+
7+
# This Action builds to os2display/* using ./infrastructure/os2display/*
8+
name: OS2display - Build docker image (develop)
79

810
jobs:
911
docker:
@@ -31,8 +33,8 @@ jobs:
3133
- name: Build and push (API)
3234
uses: docker/build-push-action@v4
3335
with:
34-
context: ./infrastructure/display-api-service/
35-
file: ./infrastructure/display-api-service/Dockerfile
36+
context: ./infrastructure/os2display/display-api-service/
37+
file: ./infrastructure/os2display/display-api-service/Dockerfile
3638
build-args: |
3739
VERSION=${{ env.APP_VERSION }}
3840
push: true
@@ -49,8 +51,8 @@ jobs:
4951
- name: Build and push (Nginx)
5052
uses: docker/build-push-action@v4
5153
with:
52-
context: ./infrastructure/nginx/
53-
file: ./infrastructure/nginx/Dockerfile
54+
context: ./infrastructure/os2display/nginx/
55+
file: ./infrastructure/os2display/nginx/Dockerfile
5456
build-args: |
5557
APP_VERSION=${{ env.APP_VERSION }}
5658
push: true

.github/workflows/docker_build_tag.yml renamed to .github/workflows/os2display_docker_build_tag.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on:
33
push:
44
tags:
55
- '*'
6-
name: Build docker image (tag)
6+
7+
# This Action builds to os2display/* using ./infrastructure/os2display/*
8+
name: OS2display - Build docker image (tag)
79

810
jobs:
911
docker:
@@ -30,8 +32,8 @@ jobs:
3032
- name: Build and push (API)
3133
uses: docker/build-push-action@v4
3234
with:
33-
context: ./infrastructure/display-api-service/
34-
file: ./infrastructure/display-api-service/Dockerfile
35+
context: ./infrastructure/os2display/display-api-service/
36+
file: ./infrastructure/os2display/display-api-service/Dockerfile
3537
build-args: |
3638
APP_VERSION=${{ github.ref }}
3739
push: true
@@ -52,8 +54,8 @@ jobs:
5254
- name: Build and push (Nginx)
5355
uses: docker/build-push-action@v4
5456
with:
55-
context: ./infrastructure/nginx/
56-
file: ./infrastructure/nginx/Dockerfile
57+
context: ./infrastructure/os2display/nginx/
58+
file: ./infrastructure/os2display/nginx/Dockerfile
5759
build-args: |
5860
APP_VERSION=${{ steps.get_tag.outputs.git_tag }}
5961
push: true

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
1010
- Minor update of composer packages
1111
- Updated psalm to version 5.x
1212
- Fixed feed data provider id issue [#151](https://github.com/os2display/display-api-service/pull/151)
13+
- Set up separate image builds for itkdev and os2display
1314

1415
## [1.2.8] - 2023-05-25
1516

infrastructure/itkdev/Readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ITK-development image build
2+
3+
This folder contains the infrastructure files for building the `itkdev/*` images
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM itkdev/php8.1-fpm:alpine AS APP_BUILDER
2+
LABEL maintainer="ITK Dev <itkdev@mkb.aarhus.dk>"
3+
4+
ARG APP_VERSION="develop"
5+
ENV APP_PATH=/var/www/html
6+
7+
USER root
8+
9+
# Move site into the container.
10+
ADD https://github.com/os2display/display-api-service/archive/${APP_VERSION}.tar.gz /tmp/app.tar
11+
RUN tar -zxf /tmp/app.tar --strip-components=1 -C ${APP_PATH} \
12+
&& rm /tmp/app.tar
13+
14+
# Add composer in from the official composer image (also alpine).
15+
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
16+
17+
WORKDIR ${APP_PATH}
18+
19+
## Install assets, which requires a HACK as redis is not available (should be removed later on).
20+
RUN APP_ENV=prod composer install --no-dev -o --classmap-authoritative \
21+
&& rm -rf infrastructure \
22+
&& APP_ENV=prod composer clear-cache
23+
24+
####
25+
## Build main application image.
26+
####
27+
FROM itkdev/php8.1-fpm:alpine
28+
LABEL maintainer="ITK Dev <itkdev@mkb.aarhus.dk>"
29+
30+
ENV APP_PATH=/var/www/html \
31+
COMPOSER_VERSION=2
32+
33+
USER root
34+
35+
# Add composer needed to run optimizations after config is loaded.
36+
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
37+
38+
# Install the application.
39+
COPY --from=APP_BUILDER ${APP_PATH} ${APP_PATH}
40+
RUN mkdir -p ${APP_PATH}/config/secrets \
41+
&& chown -R deploy:deploy ${APP_PATH}
42+
43+
# Download Prometheus php-fpm export.
44+
COPY --from=hipages/php-fpm_exporter:1.1.1 /php-fpm_exporter /usr/local/bin/php-fpm_exporter
45+
46+
# Copy configuration.
47+
COPY etc /etc/
48+
49+
# Install configuration template handler
50+
ADD https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64 /usr/local/bin/confd
51+
RUN chmod +x /usr/local/bin/confd
52+
53+
# Copy confd onfiguration.
54+
COPY etc /etc/
55+
56+
COPY docker-entrypoint.sh /usr/local/bin/
57+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
58+
59+
USER deploy
60+
61+
WORKDIR ${APP_PATH}
62+
63+
CMD [ "docker-entrypoint.sh" ]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
set -eux
4+
5+
## Run templates with configuration.
6+
/usr/local/bin/confd --onetime --backend env --confdir /etc/confd
7+
8+
## Bump env.local into PHP for better performance.
9+
composer dump-env prod
10+
11+
## Warm-up Symfony cache (with the current configuration).
12+
/var/www/html/bin/console --env=prod cache:warmup
13+
14+
## Set selected composer version. Default version 2.
15+
if [ ! -z "${COMPOSER_VERSION}" ]; then
16+
if [ "${COMPOSER_VERSION}" = "1" ]; then
17+
ln -fs /usr/bin/composer1 /home/deploy/bin/composer
18+
else
19+
ln -fs /usr/bin/composer2 /home/deploy/bin/composer
20+
fi
21+
else
22+
ln -fs /usr/bin/composer2 /home/deploy/bin/composer
23+
fi
24+
25+
exec php-fpm "$@"

infrastructure/display-api-service/etc/confd/conf.d/env.local.toml renamed to infrastructure/itkdev/display-api-service/etc/confd/conf.d/env.local.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ owner = "deploy"
55
mode = "0644"
66
keys = [
77
"/app-config"
8-
]
8+
]

0 commit comments

Comments
 (0)