This commit is contained in:
parent
21a87a3eb3
commit
fb6a61d5b6
43
.gitea/workflows/deploy.yml
Normal file
43
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Docker CLI
|
||||
run: |
|
||||
apt-get update && apt-get install -y docker.io
|
||||
|
||||
- name: Build production image
|
||||
run: |
|
||||
docker build \
|
||||
--target frankenphp_prod \
|
||||
-t mangarr:latest \
|
||||
-t mangarr:${{ gitea.sha }} \
|
||||
.
|
||||
|
||||
- name: Deploy containers
|
||||
run: |
|
||||
# Redemarrer le container principal avec la nouvelle image
|
||||
docker stop mangarr mangarr-worker 2>/dev/null || true
|
||||
docker rm mangarr mangarr-worker 2>/dev/null || true
|
||||
# Portainer va recréer les containers via la stack
|
||||
echo "Image mangarr:latest buildée avec succès"
|
||||
echo "Redéployez la stack via : deploy-stacks.sh mangarr"
|
||||
|
||||
- name: Run migrations
|
||||
run: |
|
||||
# Attendre que le container soit prêt
|
||||
sleep 10
|
||||
docker exec mangarr php bin/console doctrine:migrations:migrate --no-interaction 2>/dev/null || echo "Migrations: container pas encore prêt, lancer manuellement"
|
||||
docker exec mangarr php bin/console cache:clear --env=prod 2>/dev/null || true
|
||||
12
Dockerfile
12
Dockerfile
@@ -85,6 +85,15 @@ COPY --link frankenphp/conf.d/app.dev.ini $PHP_INI_DIR/conf.d/
|
||||
|
||||
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ]
|
||||
|
||||
# Stage Node.js pour compiler les assets (Webpack Encore)
|
||||
FROM node:22-alpine AS node_build
|
||||
WORKDIR /app
|
||||
COPY --link package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY --link assets ./assets
|
||||
COPY --link webpack.config.js ./
|
||||
RUN npm run build
|
||||
|
||||
# Prod FrankenPHP image
|
||||
FROM frankenphp_base AS frankenphp_prod
|
||||
|
||||
@@ -105,6 +114,9 @@ RUN set -eux; \
|
||||
COPY --link . ./
|
||||
RUN rm -Rf frankenphp/
|
||||
|
||||
# Copier les assets compilés depuis le stage Node.js
|
||||
COPY --from=node_build /app/public/build ./public/build
|
||||
|
||||
RUN set -eux; \
|
||||
mkdir -p var/cache var/log; \
|
||||
composer dump-autoload --classmap-authoritative --no-dev; \
|
||||
|
||||
Reference in New Issue
Block a user