Skip to content

Commit

Permalink
Revert "chore: change from php-fpm to frankenphp"
Browse files Browse the repository at this point in the history
This reverts commit efa0150
  • Loading branch information
BacLuc committed Jan 21, 2025
1 parent c6dab0a commit 8c87a95
Show file tree
Hide file tree
Showing 33 changed files with 744 additions and 145 deletions.
Empty file added .caddy/config-cache/.gitkeep
Empty file.
Empty file added .caddy/php-socket/.gitkeep
Empty file.
19 changes: 16 additions & 3 deletions .github/workflows/reusable-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,26 @@ jobs:
push: true
file: api/Dockerfile
tags: |
${{ ((inputs.tag != '') && format('{0}/ecamp3-api:{1}', vars.DOCKER_HUB_USERNAME, inputs.tag) || '') }}
${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-api:${{ inputs.sha }}
${{ ((inputs.tag != '') && format('{0}/ecamp3-api-php:{1}', vars.DOCKER_HUB_USERNAME, inputs.tag) || '') }}
${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-api-php:${{ inputs.sha }}
context: './api'
target: frankenphp_prod
target: api_platform_php
cache-from: type=gha,scope=api
cache-to: type=gha,scope=api,mode=max

- name: Build and push caddy docker image
uses: docker/build-push-action@v6
with:
push: true
file: api/Dockerfile
tags: |
${{ ((inputs.tag != '') && format('{0}/ecamp3-api-caddy:{1}', vars.DOCKER_HUB_USERNAME, inputs.tag) || '') }}
${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-api-caddy:${{ inputs.sha }}
context: './api'
target: api_platform_caddy
cache-from: type=gha,scope=caddy
cache-to: type=gha,scope=caddy,mode=max

- name: Build and push print docker image
uses: docker/build-push-action@v6
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/reusable-dev-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ jobs:
--set imageTag=${{ inputs.sha }} \
--set frontend.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-frontend' \
--set print.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-print' \
--set api.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-api' \
--set php.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-api-php' \
--set caddy.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-api-caddy' \
--set apiCache.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-varnish' \
--set postgresql.dbBackupRestoreImage.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-db-backup-restore' \
--set termsOfServiceLinkTemplate='https://ecamp3.ch/{lang}/tos' \
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/reusable-e2e-tests-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,29 @@ jobs:
context: './api'
push: false
load: true
target: frankenphp_prod
target: api_platform_php
builder: ${{ steps.buildx.outputs.name }}
tags: ecamp/ecamp3-dev-api
tags: ecamp/ecamp3-api-php
cache-from: type=gha,scope=api
cache-to: type=gha,scope=api,mode=max
outputs: type=docker,dest=/tmp/ecamp3-dev-api.tar
outputs: type=docker,dest=/tmp/ecamp3-api-php.tar

# build caddy (using cache; provide image to docker compose)
- name: Build docker image (Caddy)
uses: docker/build-push-action@v5
with:
file: api/Dockerfile
context: './api'
push: false
load: true
target: api_platform_caddy
builder: ${{ steps.buildx.outputs.name }}
tags: ecamp/ecamp3-api-caddy
cache-from: type=gha,scope=caddy
cache-to: type=gha,scope=caddy,mode=max
outputs: type=docker,dest=/tmp/ecamp3-api-caddy.tar

- uses: actions/upload-artifact@v4
with:
name: e2e-tests-images
path: /tmp/ecamp3-dev-*.tar
path: /tmp/ecamp3-*.tar
5 changes: 3 additions & 2 deletions .github/workflows/reusable-e2e-tests-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:

- name: Load images
run: |
docker load --input /tmp/ecamp3-dev-api.tar
docker load --input /tmp/ecamp3-api-php.tar
docker load --input /tmp/ecamp3-api-caddy.tar
docker image ls -a --digests
- name: Restore cache volumes (npm, composer)
Expand All @@ -64,7 +65,7 @@ jobs:
- run: docker compose -f docker-compose.yml run --rm api migrate-database

# start necessary containers
- run: docker compose -f docker-compose.yml up -d api frontend pdf print browserless database docker-host http-cache mail pg-admin reverse-proxy
- run: docker compose -f docker-compose.yml up -d php caddy frontend pdf print browserless database docker-host http-cache mail pg-admin reverse-proxy

# pull cypress while container are starting up
- run: docker compose pull e2e
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/reusable-stage-prod-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:
--set imageTag=${{ github.sha }} \
--set frontend.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-frontend' \
--set print.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-print' \
--set api.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-api' \
--set php.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-api-php' \
--set caddy.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-api-caddy' \
--set apiCache.image.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-varnish' \
--set postgresql.dbBackupRestoreImage.repository='docker.io/${{ vars.DOCKER_HUB_USERNAME }}/ecamp3-db-backup-restore' \
--set termsOfServiceLinkTemplate='https://ecamp3.ch/{lang}/tos' \
Expand Down Expand Up @@ -102,9 +103,11 @@ jobs:
--set browserless.connectionTimeout=${{ vars.BROWSERLESS_CONNECTION_TIMEOUT_MS || '30000' }} \
--set browserless.resources.requests.cpu=${{ vars.BROWSERLESS_CPU || '500m' }} \
--set browserless.resources.requests.memory=${{ vars.BROWSERLESS_MEMORY || '800Mi' }} \
--set api.resources.requests.cpu=${{ vars.PHP_CPU || '1000m' }} \
--set api.resources.requests.memory=${{ vars.PHP_MEMORY || '500Mi' }} \
--set api.resources.limits.cpu=${{ vars.PHP_CPULIMIT || '1900m' }} \
--set caddy.resources.requests.cpu=50m \
--set caddy.resources.limits.cpu=500m \
--set php.resources.requests.cpu=${{ vars.PHP_CPU || '1000m' }} \
--set php.resources.requests.memory=${{ vars.PHP_MEMORY || '500Mi' }} \
--set php.resources.limits.cpu=${{ vars.PHP_CPULIMIT || '1900m' }} \
--set frontend.resources.requests.cpu=50m \
--set print.resources.requests.cpu=${{ vars.PRINT_CPU || '300m' }} \
--set print.resources.requests.memory=${{ vars.PRINT_MEMORY || '150Mi' }} \
Expand Down
8 changes: 6 additions & 2 deletions .helm/build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ frontend_image_tag="${docker_hub_account}/ecamp3-frontend:${version}"
docker build "$REPO_DIR" -f "$REPO_DIR"/.docker-hub/frontend/Dockerfile $frontend_sentry_build_args -t "$frontend_image_tag"
docker push "$frontend_image_tag"

api_image_tag="${docker_hub_account}/ecamp3-api:${version}"
docker build "$REPO_DIR"/api -f "$REPO_DIR"/api/Dockerfile -t "$api_image_tag" --target frankenphp_prod $sentry_build_args
api_image_tag="${docker_hub_account}/ecamp3-api-php:${version}"
docker build "$REPO_DIR"/api -f "$REPO_DIR"/api/Dockerfile -t "$api_image_tag" --target api_platform_php $sentry_build_args
docker push "$api_image_tag"

caddy_image_tag="${docker_hub_account}/ecamp3-api-caddy:${version}"
docker build "$REPO_DIR"/api -f "$REPO_DIR"/api/Dockerfile -t "$caddy_image_tag" --target api_platform_caddy
docker push "$caddy_image_tag"

print_sentry_build_args="$sentry_build_args --build-arg SENTRY_PRINT_PROJECT=$SENTRY_PRINT_PROJECT"

print_image_tag="${docker_hub_account}/ecamp3-print:${version}"
Expand Down
7 changes: 6 additions & 1 deletion .helm/deploy-to-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,16 @@ for i in 1; do
values="$values --set postgresql.restore.inviteSupportAccountToInterestingCamps=$RESTORE_INVITE_TO_INTERESTING_CAMPS"
fi

for imagespec in "frontend" "print" "api"; do
for imagespec in "frontend" "print"; do
values="$values --set $imagespec.image.pullPolicy=$pull_policy"
values="$values --set $imagespec.image.repository=docker.io/${docker_hub_account}/ecamp3-$imagespec"
done

for imagespec in "php" "caddy"; do
values="$values --set $imagespec.image.pullPolicy=$pull_policy"
values="$values --set $imagespec.image.repository=docker.io/${docker_hub_account}/ecamp3-api-$imagespec"
done

values="$values --set apiCache.image.repository=docker.io/${docker_hub_account}/ecamp3-varnish"

values="$values --set postgresql.dbBackupRestoreImage.pullPolicy=$pull_policy"
Expand Down
55 changes: 44 additions & 11 deletions .helm/ecamp3/templates/api_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,49 @@ spec:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
enableServiceLinks: false
containers:
- name: {{ .Chart.Name }}-api
{{/* Define the api container as a template, so it can be reused in other places */}}
{{- define "api.container" }}
- name: {{ .Chart.Name }}-caddy
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Values.imageTag }}"
imagePullPolicy: {{ .Values.api.image.pullPolicy }}
image: "{{ .Values.caddy.image.repository }}:{{ .Values.caddy.image.tag | default .Values.imageTag }}"
imagePullPolicy: {{ .Values.caddy.image.pullPolicy }}
env:
- name: SERVER_NAME
value: :3001
ports:
- name: api-http
containerPort: {{ .Values.api.service.port }}
protocol: TCP
- name: api-metrics
containerPort: {{ .Values.api.metrics.port }}
protocol: TCP
protocol: TCP
volumeMounts:
- mountPath: /var/run/php
name: php-socket
lifecycle:
preStop:
exec:
command: ["curl", "-XPOST", "http://localhost:2019/stop"]
readinessProbe:
tcpSocket:
port: 3001
initialDelaySeconds: 3
periodSeconds: 10
timeoutSeconds: 5
livenessProbe:
tcpSocket:
port: 3001
initialDelaySeconds: 3
periodSeconds: 10
timeoutSeconds: 5
resources:
{{- toYaml .Values.caddy.resources | nindent 12 }}
- name: php
{{/* Define the php container as a template, so it can be reused in other places */}}
{{- define "api.phpContainer" }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Values.imageTag }}"
imagePullPolicy: {{ .Values.php.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "api.name" . }}-configmap
Expand Down Expand Up @@ -142,6 +171,8 @@ spec:
key: oauth-jubladb-base-url
{{- end }}
volumeMounts:
- mountPath: /var/run/php
name: php-socket
- mountPath: /app/config/jwt/public.pem
name: jwt-keypair
subPath: public.pem
Expand All @@ -155,15 +186,17 @@ spec:
{{- end }}
{{- template "api.container" . }}
resources:
{{- toYaml .Values.api.resources | nindent 12 }}
{{- toYaml .Values.php.resources | nindent 12 }}
readinessProbe:
tcpSocket:
port: 3001
exec:
command:
- docker-healthcheck
periodSeconds: 10
timeoutSeconds: 5
livenessProbe:
tcpSocket:
port: 3001
exec:
command:
- docker-healthcheck
periodSeconds: 10
timeoutSeconds: 5
startupProbe:
Expand Down
2 changes: 1 addition & 1 deletion .helm/ecamp3/templates/hook_db_create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
restartPolicy: Never
containers:
- name: db-create-job
image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Values.imageTag }}"
image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Values.imageTag }}"
command: ["php", "bin/console", "doctrine:database:create", "--if-not-exists"]
env:
- name: DATABASE_URL
Expand Down
2 changes: 1 addition & 1 deletion .helm/ecamp3/templates/hook_db_drop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
restartPolicy: Never
containers:
- name: db-drop-job
image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Values.imageTag }}"
image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Values.imageTag }}"
command: ["php", "bin/console", "doctrine:database:drop", "--if-exists", "-f"]
env:
- name: DATABASE_URL
Expand Down
23 changes: 18 additions & 5 deletions .helm/ecamp3/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ featureToggle:

api:
subpath: "/api"
image:
repository: "docker.io/ecamp/ecamp3-api"
pullPolicy: IfNotPresent
# Overrides the image tag whose shared default is .Values.imageTag
tag:
service:
type: ClusterIP
port: 3001
metrics:
port: 2019
replicaCount: 1

php:
image:
repository: "docker.io/ecamp/ecamp3-api-php"
pullPolicy: IfNotPresent
# Overrides the image tag whose shared default is .Values.imageTag
tag:
appEnv: prod
appDebug: "0"
appSecret: ""
Expand Down Expand Up @@ -67,6 +69,17 @@ api:
cpu: 10m
memory: 120Mi

caddy:
image:
repository: "docker.io/ecamp/ecamp3-api-caddy"
pullPolicy: IfNotPresent
# Overrides the image tag whose shared default is .Values.imageTag
tag:
resources:
requests:
cpu: 10m
memory: 20Mi

frontend:
image:
repository: "docker.io/ecamp/ecamp3-frontend"
Expand Down
Loading

0 comments on commit 8c87a95

Please sign in to comment.