Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/github_build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
docker compose run --rm phpfpm composer clear-cache
rm -rf infrastructure

- name: Make artefacts dir
- name: Make assets dir
run: |
mkdir -p ../assets

Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/itkdev_docker_build_develop.yml
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 }}
63 changes: 63 additions & 0 deletions .github/workflows/itkdev_docker_build_tag.yml
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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ on:
push:
branches:
- 'develop'
name: Build docker image (develop)

# This Action builds to os2display/* using ./infrastructure/os2display/*
name: OS2display - Build docker image (develop)

jobs:
docker:
Expand Down Expand Up @@ -31,8 +33,8 @@ jobs:
- name: Build and push (API)
uses: docker/build-push-action@v4
with:
context: ./infrastructure/display-api-service/
file: ./infrastructure/display-api-service/Dockerfile
context: ./infrastructure/os2display/display-api-service/
file: ./infrastructure/os2display/display-api-service/Dockerfile
build-args: |
VERSION=${{ env.APP_VERSION }}
push: true
Expand All @@ -49,8 +51,8 @@ jobs:
- name: Build and push (Nginx)
uses: docker/build-push-action@v4
with:
context: ./infrastructure/nginx/
file: ./infrastructure/nginx/Dockerfile
context: ./infrastructure/os2display/nginx/
file: ./infrastructure/os2display/nginx/Dockerfile
build-args: |
APP_VERSION=${{ env.APP_VERSION }}
push: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ on:
push:
tags:
- '*'
name: Build docker image (tag)

# This Action builds to os2display/* using ./infrastructure/os2display/*
name: OS2display - Build docker image (tag)

jobs:
docker:
Expand All @@ -30,8 +32,8 @@ jobs:
- name: Build and push (API)
uses: docker/build-push-action@v4
with:
context: ./infrastructure/display-api-service/
file: ./infrastructure/display-api-service/Dockerfile
context: ./infrastructure/os2display/display-api-service/
file: ./infrastructure/os2display/display-api-service/Dockerfile
build-args: |
APP_VERSION=${{ github.ref }}
push: true
Expand All @@ -52,8 +54,8 @@ jobs:
- name: Build and push (Nginx)
uses: docker/build-push-action@v4
with:
context: ./infrastructure/nginx/
file: ./infrastructure/nginx/Dockerfile
context: ./infrastructure/os2display/nginx/
file: ./infrastructure/os2display/nginx/Dockerfile
build-args: |
APP_VERSION=${{ steps.get_tag.outputs.git_tag }}
push: true
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
- Minor update of composer packages
- Updated psalm to version 5.x
- Fixed feed data provider id issue [#151](https://github.com/os2display/display-api-service/pull/151)
- Set up separate image builds for itkdev and os2display

## [1.2.8] - 2023-05-25

Expand Down
3 changes: 3 additions & 0 deletions infrastructure/itkdev/Readme.md
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
63 changes: 63 additions & 0 deletions infrastructure/itkdev/display-api-service/Dockerfile
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 <itkdev@mkb.aarhus.dk>"

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 <itkdev@mkb.aarhus.dk>"

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 infrastructure/itkdev/display-api-service/docker-entrypoint.sh
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 "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ owner = "deploy"
mode = "0644"
keys = [
"/app-config"
]
]
37 changes: 37 additions & 0 deletions infrastructure/itkdev/nginx/Dockerfile
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 <itkdev@mkb.aarhus.dk>"
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;"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dest = "/etc/nginx/conf.d/default.conf"
mode = "0644"
keys = [
"/nginx-config"
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ dest = "/etc/nginx/nginx.conf"
mode = "0644"
keys = [
"/nginx-config"
]
]
13 changes: 13 additions & 0 deletions infrastructure/itkdev/run.sh
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}
3 changes: 3 additions & 0 deletions infrastructure/os2display/Readme.md
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ RUN mkdir -p ${APP_PATH}/config/secrets \
&& chown -R www-data:www-data ${APP_PATH}

# Copy configuration.
COPY etc/ /etc/
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 etc /etc/

COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
Expand Down
Loading