-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from os2display/feature/DISPLAY-986_build_sep…
…arate_images DISPLAY-986: Setup separate image builds for itkdev and os2display
- Loading branch information
Showing
35 changed files
with
504 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
on: | ||
push: | ||
branches: | ||
- 'develop' | ||
|
||
# This Action builds to itkdev/* using ./infrastructure/itkdev/* | ||
name: ITK Dev - Build docker image (develop) | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
env: | ||
APP_VERSION: develop | ||
COMPOSER_ALLOW_SUPERUSER: 1 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Build api | ||
- name: Docker meta (API) | ||
id: meta-api | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: itkdev/os2display-api-service | ||
|
||
- name: Build and push (API) | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./infrastructure/itkdev/display-api-service/ | ||
file: ./infrastructure/itkdev/display-api-service/Dockerfile | ||
build-args: | | ||
VERSION=${{ env.APP_VERSION }} | ||
push: true | ||
tags: ${{ steps.meta-api.outputs.tags }} | ||
labels: ${{ steps.meta-api.outputs.labels }} | ||
|
||
# Build nginx (depends on api build) | ||
- name: Docker meta (Nginx) | ||
id: meta-nginx | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: itkdev/os2display-api-service-nginx | ||
|
||
- name: Build and push (Nginx) | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./infrastructure/itkdev/nginx/ | ||
file: ./infrastructure/itkdev/nginx/Dockerfile | ||
build-args: | | ||
APP_VERSION=${{ env.APP_VERSION }} | ||
push: true | ||
tags: ${{ steps.meta-nginx.outputs.tags }} | ||
labels: ${{ steps.meta-nginx.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
# This Action builds to itkdev/* using ./infrastructure/itkdev/* | ||
name: ITK Dev - Build docker image (tag) | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
env: | ||
COMPOSER_ALLOW_SUPERUSER: 1 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Build api | ||
- name: Docker meta (API) | ||
id: meta-api | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: itkdev/os2display-api-service | ||
|
||
- name: Build and push (API) | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./infrastructure/itkdev/display-api-service/ | ||
file: ./infrastructure/itkdev/display-api-service/Dockerfile | ||
build-args: | | ||
APP_VERSION=${{ github.ref }} | ||
push: true | ||
tags: ${{ steps.meta-api.outputs.tags }} | ||
labels: ${{ steps.meta-api.outputs.labels }} | ||
|
||
# Build nginx (depends on api build) | ||
- name: Docker meta (Nginx) | ||
id: meta-nginx | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: itkdev/os2display-api-service-nginx | ||
|
||
- name: Get the tag | ||
id: get_tag | ||
run: echo ::set-output name=git_tag::$(echo $GITHUB_REF_NAME) | ||
|
||
- name: Build and push (Nginx) | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./infrastructure/itkdev/nginx/ | ||
file: ./infrastructure/itkdev/nginx/Dockerfile | ||
build-args: | | ||
APP_VERSION=${{ steps.get_tag.outputs.git_tag }} | ||
push: true | ||
tags: ${{ steps.meta-nginx.outputs.tags }} | ||
labels: ${{ steps.meta-nginx.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ITK-development image build | ||
|
||
This folder contains the infrastructure files for building the `itkdev/*` images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
FROM itkdev/php8.1-fpm:alpine AS APP_BUILDER | ||
LABEL maintainer="ITK Dev <[email protected]>" | ||
|
||
ARG APP_VERSION="develop" | ||
ENV APP_PATH=/var/www/html | ||
|
||
USER root | ||
|
||
# Move site into the container. | ||
ADD https://github.com/os2display/display-api-service/archive/${APP_VERSION}.tar.gz /tmp/app.tar | ||
RUN tar -zxf /tmp/app.tar --strip-components=1 -C ${APP_PATH} \ | ||
&& rm /tmp/app.tar | ||
|
||
# Add composer in from the official composer image (also alpine). | ||
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer | ||
|
||
WORKDIR ${APP_PATH} | ||
|
||
## Install assets, which requires a HACK as redis is not available (should be removed later on). | ||
RUN APP_ENV=prod composer install --no-dev -o --classmap-authoritative \ | ||
&& rm -rf infrastructure \ | ||
&& APP_ENV=prod composer clear-cache | ||
|
||
#### | ||
## Build main application image. | ||
#### | ||
FROM itkdev/php8.1-fpm:alpine | ||
LABEL maintainer="ITK Dev <[email protected]>" | ||
|
||
ENV APP_PATH=/var/www/html \ | ||
COMPOSER_VERSION=2 | ||
|
||
USER root | ||
|
||
# Add composer needed to run optimizations after config is loaded. | ||
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer | ||
|
||
# Install the application. | ||
COPY --from=APP_BUILDER ${APP_PATH} ${APP_PATH} | ||
RUN mkdir -p ${APP_PATH}/config/secrets \ | ||
&& chown -R deploy:deploy ${APP_PATH} | ||
|
||
# Download Prometheus php-fpm export. | ||
COPY --from=hipages/php-fpm_exporter:1.1.1 /php-fpm_exporter /usr/local/bin/php-fpm_exporter | ||
|
||
# Copy configuration. | ||
COPY etc /etc/ | ||
|
||
# Install configuration template handler | ||
ADD https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64 /usr/local/bin/confd | ||
RUN chmod +x /usr/local/bin/confd | ||
|
||
# Copy confd onfiguration. | ||
COPY etc /etc/ | ||
|
||
COPY docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
|
||
USER deploy | ||
|
||
WORKDIR ${APP_PATH} | ||
|
||
CMD [ "docker-entrypoint.sh" ] |
25 changes: 25 additions & 0 deletions
25
infrastructure/itkdev/display-api-service/docker-entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
|
||
set -eux | ||
|
||
## Run templates with configuration. | ||
/usr/local/bin/confd --onetime --backend env --confdir /etc/confd | ||
|
||
## Bump env.local into PHP for better performance. | ||
composer dump-env prod | ||
|
||
## Warm-up Symfony cache (with the current configuration). | ||
/var/www/html/bin/console --env=prod cache:warmup | ||
|
||
## Set selected composer version. Default version 2. | ||
if [ ! -z "${COMPOSER_VERSION}" ]; then | ||
if [ "${COMPOSER_VERSION}" = "1" ]; then | ||
ln -fs /usr/bin/composer1 /home/deploy/bin/composer | ||
else | ||
ln -fs /usr/bin/composer2 /home/deploy/bin/composer | ||
fi | ||
else | ||
ln -fs /usr/bin/composer2 /home/deploy/bin/composer | ||
fi | ||
|
||
exec php-fpm "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ owner = "deploy" | |
mode = "0644" | ||
keys = [ | ||
"/app-config" | ||
] | ||
] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
ARG APP_VERSION="develop" | ||
FROM itkdev/os2display-api-service:${APP_VERSION} as APPLICATION | ||
|
||
FROM nginxinc/nginx-unprivileged:alpine | ||
LABEL maintainer="ITK Dev <[email protected]>" | ||
ARG UID=101 | ||
ARG GID=101 | ||
|
||
ENV APP_PATH=/var/www/html | ||
|
||
USER root | ||
|
||
RUN mkdir -p ${APP_PATH}/public | ||
|
||
COPY --from=APPLICATION ${APP_PATH}/public ${APP_PATH}/public | ||
|
||
WORKDIR ${APP_PATH} | ||
|
||
# Copy configuration. | ||
COPY etc/ /etc/ | ||
|
||
# Install configuration template handler | ||
ADD https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64 /usr/local/bin/confd | ||
RUN chmod +x /usr/local/bin/confd | ||
|
||
COPY docker-entrypoint.sh / | ||
RUN chmod +x /docker-entrypoint.sh \ | ||
&& chown -R $UID:0 ${APP_PATH} \ | ||
&& chmod -R g+w ${APP_PATH} | ||
|
||
USER $UID | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT [ "/docker-entrypoint.sh" ] | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ dest = "/etc/nginx/conf.d/default.conf" | |
mode = "0644" | ||
keys = [ | ||
"/nginx-config" | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ dest = "/etc/nginx/nginx.conf" | |
mode = "0644" | ||
keys = [ | ||
"/nginx-config" | ||
] | ||
] |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
set -eux | ||
|
||
APP_VERSION=develop | ||
|
||
docker pull nginxinc/nginx-unprivileged:alpine | ||
|
||
docker build --pull --no-cache --build-arg APP_VERSION=${APP_VERSION} --tag=itkdev/os2display-api-service:${APP_VERSION} --file="display-api-service/Dockerfile" display-api-service | ||
docker build --no-cache --build-arg VERSION=${APP_VERSION} --tag=itkdev/os2display-api-service-nginx:${APP_VERSION} --file="nginx/Dockerfile" nginx | ||
|
||
# docker push itkdev/os2display-api-service:${APP_VERSION} | ||
# docker push itkdev/os2display-api-service-nginx:${APP_VERSION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# OS2display image build | ||
|
||
This folder contains the infrastructure files for building the `os2display/*` images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.