diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..9602add --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,20 @@ +on: + release +jobs: + ls: + runs-on: docker + container: + image: git.php.fail/lubiana/container/php:ci + steps: + - name: Manually checkout + env: + REPO: '${{ github.repository }}' + TOKEN: '${{ secrets.GITHUB_TOKEN }}' + BRANCH: '${{ env.GITHUB_REF_NAME }}' + GIT_SERVER: 'hannover.ccc.de/gitlab' + run: | + git clone --branch $GITHUB_REF_NAME https://${TOKEN}@${GIT_SERVER}/${REPO}.git . + git fetch + git checkout ${{ github.head_ref }} + - name: list + run: ls diff --git a/.gitignore b/.gitignore index 9a35500..62752be 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,6 @@ .phpunit.result.cache ###< phpunit/phpunit ### -.idea/ \ No newline at end of file +.idea/ +/deploy/futtern-app/ +/deploy/var/ diff --git a/composer.json b/composer.json index 273625d..9a7f726 100644 --- a/composer.json +++ b/composer.json @@ -70,11 +70,11 @@ "assets:install %PUBLIC_DIR%": "symfony-cmd" }, "post-install-cmd": [ - "@auto-scripts", - "config-transformer switch-format config" + "@auto-scripts" ], "post-update-cmd": [ - "@auto-scripts" + "@auto-scripts", + "config-transformer switch-format config" ], "lint": [ "rector", diff --git a/deploy/Dockerfile b/deploy/Dockerfile new file mode 100644 index 0000000..47bc55b --- /dev/null +++ b/deploy/Dockerfile @@ -0,0 +1,2 @@ +FROM git.php.fail/lubiana/container/php:8.3 as phpbuild + diff --git a/deploy/etc/caddy/Caddyfile b/deploy/etc/caddy/Caddyfile new file mode 100644 index 0000000..a36f02d --- /dev/null +++ b/deploy/etc/caddy/Caddyfile @@ -0,0 +1,7 @@ +:8087 { + log + root * /var/www/html/public + php_fastcgi localhost:9001 + file_server + encode zstd gzip +} \ No newline at end of file diff --git a/deploy/etc/php83/php-fpm.d/www.conf b/deploy/etc/php83/php-fpm.d/www.conf new file mode 100644 index 0000000..113b8c2 --- /dev/null +++ b/deploy/etc/php83/php-fpm.d/www.conf @@ -0,0 +1,10 @@ +[www] + +user = nobody +group = nobody +listen = 9001 +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 \ No newline at end of file diff --git a/deploy/install.sh b/deploy/install.sh new file mode 100755 index 0000000..d4b64b7 --- /dev/null +++ b/deploy/install.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env sh + +if [ ! -d "var" ]; then + mkdir var +fi +podman pod stop futtern +podman pod rm futtern + +podman pod create \ + --label "io.containers.autoupdate=registry" \ + --name futtern \ + -p 8087:8087 + +podman run -d \ + --pod futtern \ + --name futtern-php \ + --volume $(pwd)/etc/php83/php-fpm.d/www.conf:/etc/php83/php-fpm.d/www.conf \ + --volume $(pwd)/futtern-app:/var/www/html \ + --volume $(pwd)/var:/var/www/html/var \ + --env 'APP_ENV=prod' \ + git.php.fail/lubiana/container/php:8.3-fpm + +podman run -d \ + --pod futtern \ + --name futtern-caddy \ + --volume $(pwd)/etc/caddy/Caddyfile:/etc/caddy/Caddyfile \ + --volume $(pwd)/futtern-app:/var/www/html \ + --volume caddy_data:/data \ + docker.io/caddy/caddy:alpine + +echo 'yes' | podman exec -it futtern-php /var/www/html/bin/console doctrine:migrations:migrate diff --git a/deploy/prepare-deploy.sh b/deploy/prepare-deploy.sh new file mode 100644 index 0000000..c0ad1ed --- /dev/null +++ b/deploy/prepare-deploy.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +TARGETDIR='futtern-app' + +if [ -d $TARGETDIR ]; then + rm -rf $TARGETDIR +fi +mkdir $TARGETDIR +cd $TARGETDIR || return + +pathsToCopy="public bin config migrations src templates composer.json composer.lock symfony.lock .env etc" + +for path in $pathsToCopy +do + cp -r ../../"$path" ./ +done + +rm ./bin/phpunit +APP_ENV=prod composer install --no-dev -a +mkdir -p ~/.ssh/ +# Print the SSH key, replacing newline characters with actual new lines +echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa +# Set appropriate permissions for the SSH key +chmod 600 ~/.ssh/id_rsa +# Add the remote host's key to the known_hosts file to avoid authenticity confirmation +ssh-keyscan -H $HOST >> ~/.ssh/known_hosts +# SCP files to the remote host +rsync -avz --delete public/ ${USERNAME}@${HOST}:${TARGETDIR} + + diff --git a/var/.gitkeep b/var/.gitkeep new file mode 100644 index 0000000..e69de29