Simplificar Docker a imagen única y actualizar workflow CI/CD
This commit is contained in:
@@ -5,26 +5,8 @@ on:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
#───────────────── filtra qué dirs cambiaron ─────────────────
|
||||
filter:
|
||||
runs-on: docker
|
||||
outputs:
|
||||
server: ${{ steps.paths.outputs.server }}
|
||||
client: ${{ steps.paths.outputs.client }}
|
||||
admin: ${{ steps.paths.outputs.admin }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- id: paths
|
||||
uses: dorny/paths-filter@v3
|
||||
with:
|
||||
filters: |
|
||||
server: "server/**"
|
||||
client: "client/**"
|
||||
admin: "admin/**"
|
||||
|
||||
#───────────────── build & push ─────────────────
|
||||
#───────────────── build & push imagen única ─────────────────
|
||||
build:
|
||||
needs: filter
|
||||
runs-on: docker
|
||||
env:
|
||||
REG: gitea.nucleoriofrio.com/nucleo000
|
||||
@@ -37,26 +19,11 @@ jobs:
|
||||
username: nucleo000
|
||||
password: 7bc7b2fcd283bd6a251bef3ede368b7f897c919d
|
||||
|
||||
- name: Build+push server
|
||||
if: needs.filter.outputs.server == 'true'
|
||||
- name: Build and push snatchgame
|
||||
run: |
|
||||
docker build -f server/Dockerfile -t $REG/snatchgame-server:${{ github.sha }} -t $REG/snatchgame-server:latest server
|
||||
docker push $REG/snatchgame-server:${{ github.sha }}
|
||||
docker push $REG/snatchgame-server:latest
|
||||
|
||||
- name: Build+push client
|
||||
if: needs.filter.outputs.client == 'true'
|
||||
run: |
|
||||
docker build -f client/Dockerfile -t $REG/snatchgame-client:${{ github.sha }} -t $REG/snatchgame-client:latest client
|
||||
docker push $REG/snatchgame-client:${{ github.sha }}
|
||||
docker push $REG/snatchgame-client:latest
|
||||
|
||||
- name: Build+push admin
|
||||
if: needs.filter.outputs.admin == 'true'
|
||||
run: |
|
||||
docker build -f admin/Dockerfile -t $REG/snatchgame-admin:${{ github.sha }} -t $REG/snatchgame-admin:latest admin
|
||||
docker push $REG/snatchgame-admin:${{ github.sha }}
|
||||
docker push $REG/snatchgame-admin:latest
|
||||
docker build -t $REG/snatchgame:${{ github.sha }} -t $REG/snatchgame:latest .
|
||||
docker push $REG/snatchgame:${{ github.sha }}
|
||||
docker push $REG/snatchgame:latest
|
||||
|
||||
#───────────────── deploy ─────────────────
|
||||
deploy:
|
||||
@@ -65,15 +32,23 @@ jobs:
|
||||
env:
|
||||
REG: gitea.nucleoriofrio.com/nucleo000
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Login to registry
|
||||
run: docker login gitea.nucleoriofrio.com -u nucleo000 -p 7bc7b2fcd283bd6a251bef3ede368b7f897c919d
|
||||
|
||||
- name: Pull fresh images used in compose
|
||||
run: docker compose pull --ignore-pull-failures
|
||||
- name: Stop existing container
|
||||
run: docker stop snatchgame || true
|
||||
|
||||
- name: Clean up stack
|
||||
run: docker compose --project-name snatchgame down
|
||||
- name: Remove existing container
|
||||
run: docker rm snatchgame || true
|
||||
|
||||
- name: Update stack
|
||||
run: docker compose --project-name snatchgame up -d --remove-orphans --wait
|
||||
- name: Pull latest image
|
||||
run: docker pull $REG/snatchgame:latest
|
||||
|
||||
- name: Run new container
|
||||
run: |
|
||||
docker run -d \
|
||||
--name snatchgame \
|
||||
--restart unless-stopped \
|
||||
-p 3000:3000 \
|
||||
-p 2567:2567 \
|
||||
$REG/snatchgame:latest
|
||||
Reference in New Issue
Block a user