Skip to content

Commit 3eb9b33

Browse files
committed
Add Docker build for the test application
1 parent c30c230 commit 3eb9b33

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

.github/workflows/app.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 'App Build'
2+
3+
on:
4+
workflow_run:
5+
workflows: ['CI']
6+
types:
7+
- completed
8+
9+
jobs:
10+
build:
11+
# Run only only the default branch and when the CI build was successful
12+
if: ${{ github.ref_name == github.event.repository.default_branch && github.event.workflow_run.conclusion == 'success' }}
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Login to Docker Hub
19+
uses: docker/login-action@v3
20+
with:
21+
username: ${{ secrets.DOCKERHUB_USERNAME }}
22+
password: ${{ secrets.DOCKERHUB_TOKEN }}
23+
24+
- id: meta
25+
uses: docker/metadata-action@v5
26+
with:
27+
images: scheb42/2fa-app
28+
tags: |
29+
type=sha
30+
type=ref,event=branch
31+
# set latest tag for default branch
32+
type=raw,value=latest,enable={{ is_default_branch }}
33+
34+
- name: Build and push
35+
uses: docker/build-push-action@v5
36+
with:
37+
context: .
38+
file: app/Dockerfile
39+
tags: ${{ steps.meta.outputs.tags }}
40+
labels: ${{ steps.meta.outputs.labels }}
41+
push: true

app/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM phpdockerio/php:8.4-fpm
2+
WORKDIR /application
3+
4+
# Install selected extensions and other stuff
5+
RUN apt-get update \
6+
&& apt-get -y --no-install-recommends install \
7+
php8.4-sqlite \
8+
php8.4-intl \
9+
php8.4-gd \
10+
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/log/* /var/cache/* /usr/share/doc/*
11+
12+
COPY app/bin/console ./bin/
13+
COPY app/composer.* ./
14+
COPY app/data ./data
15+
COPY app/.env ./.env
16+
COPY app/config ./config
17+
COPY app/public/index.php ./public/
18+
COPY app/src ./src
19+
COPY app/templates ./templates
20+
COPY src ./../src
21+
22+
RUN composer install --no-dev --no-scripts; \
23+
composer clear-cache; \
24+
composer dump-autoload --optimize --classmap-authoritative; \
25+
bin/console cache:warmup; \
26+
chown -R www-data:www-data ./var/; \
27+
chown -R www-data:www-data ./data/

app/docker-compose.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
webserver:
3+
image: nginx:latest
4+
ports:
5+
- '8080:80'
6+
volumes:
7+
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
8+
9+
php-fpm:
10+
image: scheb42/2fa-app
11+
build:
12+
dockerfile: app/Dockerfile
13+
context: ../

app/nginx.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server {
2+
index index.php index.html;
3+
server_name localhost;
4+
error_log /var/log/nginx/error.log;
5+
access_log /var/log/nginx/access.log;
6+
root /var/www/html;
7+
8+
location / {
9+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
10+
fastcgi_pass php-fpm:9000;
11+
fastcgi_index index.php;
12+
include fastcgi_params;
13+
fastcgi_param SCRIPT_FILENAME /application/public/index.php;
14+
}
15+
}

0 commit comments

Comments
 (0)