-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5f23a6
commit 25aa57d
Showing
4 changed files
with
89 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
# shamelessly copied from https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio | ||
# modified to meet our needs | ||
name: "Docker Image" | ||
|
||
on: | ||
push: | ||
branches: | ||
- release | ||
tags: | ||
- v* | ||
|
||
|
@@ -26,35 +22,33 @@ jobs: | |
run: | | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
[ "$VERSION" == "main" ] && VERSION=main | ||
docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${{ github.run_number }}" \ | ||
--label "org.opencontainers.image.title=The Traewelling container image" \ | ||
echo "$VERSION" > VERSION | ||
docker build . --file Dockerfile \ | ||
--tag traewelling:$VERSION \ | ||
--tag traewelling:latest \ | ||
--label "runnumber=${{ github.run_number }}" \ | ||
--label "org.opencontainers.image.title=Traewelling" \ | ||
--label "org.opencontainers.image.version=$VERSION" \ | ||
--label "org.opencontainers.image.description=Easy-to-use deployment image of the Traewelling project" \ | ||
--label "org.opencontainers.image.url=https://github.com/Traewelling/traewelling#readme" \ | ||
--label "org.opencontainers.image.source=https://github.com/Traewelling/traewelling.git" \ | ||
--label "org.opencontainers.image.authors=Jonas Möller <[email protected]>" \ | ||
--label "org.opencontainers.image.vendor=The Traewelling team <[email protected]>" \ | ||
--label "org.opencontainers.image.license=AGPL-3.0" \ | ||
--label "org.opencontainers.image.base.name=docker.io/library/php:8-apache" | ||
--label "org.opencontainers.image.vendor=The Traewelling team <[email protected]>" \ | ||
--label "org.opencontainers.image.license=AGPL-3.0" | ||
- name: Log in to registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | ||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
# Use Docker `latest` tag convention | ||
[ "$VERSION" == "release" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:latest | ||
docker push $IMAGE_ID:latest |
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 |
---|---|---|
@@ -1,13 +1,28 @@ | ||
#!/bin/bash | ||
set -e | ||
role=${CONTAINER_ROLE:-app} | ||
|
||
if [ "$1" = 'apache2-foreground' ]; then | ||
wait-for-it "$DB_HOST:${DB_PORT:=3306}" | ||
cd /var/www/html | ||
wait-for-it "$DB_HOST:${DB_PORT:=3306}" | ||
cd /var/www/html | ||
runuser -u www-data -- php artisan optimize | ||
|
||
if [ "$role" = "app" ]; then | ||
|
||
echo "Running as app..." | ||
runuser -u www-data -- php artisan migrate --force | ||
runuser -u www-data -- php artisan storage:link | ||
runuser -u www-data -- php artisan optimize | ||
apache2-foreground | ||
fi | ||
|
||
exec "$@" | ||
elif [ "$role" = "scheduler" ]; then | ||
|
||
echo "Running as scheduler..." | ||
while true | ||
do | ||
runuser -u www-data -- php artisan schedule:run --verbose --no-interaction | ||
sleep 60 | ||
done | ||
|
||
else | ||
echo "Could not match the container role \"$role\"" | ||
exit 1 | ||
fi |