Created
October 17, 2024 19:11
-
-
Save gustavorodarte/9de90cb7cf27fd3ff6a3ba0f605e8cdb to your computer and use it in GitHub Desktop.
Next App + Strapi - GITLAB CI + KAMAL2
This file contains hidden or 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
image: node:20-alpine | |
variables: | |
GIT_DEPTH: 0 | |
services: | |
- docker:dind | |
stages: | |
- install | |
- validation | |
- deploy | |
variables: | |
FRONTEND_IMAGE: $CI_REGISTRY_IMAGE/frontend:latest | |
BACKEND_IMAGE: $CI_REGISTRY_IMAGE/backend:latest | |
DOCKER_HOST: tcp://docker:2375/ | |
DOCKER_DRIVER: overlay2 | |
install_frontend: | |
stage: install | |
cache: | |
key: ${CI_COMMIT_REF_SLUG}-frontend | |
paths: | |
- frontend/node_modules | |
script: | |
- cd frontend && npm ci | |
install_backend: | |
stage: install | |
cache: | |
key: ${CI_COMMIT_REF_SLUG}-backend | |
paths: | |
- backend/node_modules | |
script: | |
- cd backend && npm ci | |
lint_frontend: | |
stage: validation | |
cache: | |
key: ${CI_COMMIT_REF_SLUG}-frontend | |
paths: | |
- frontend/node_modules/ | |
script: | |
- cd frontend && npm run lint | |
needs: ["install_frontend"] | |
lint_backend: | |
stage: validation | |
cache: | |
key: ${CI_COMMIT_REF_SLUG}-backend | |
paths: | |
- backend/node_modules/ | |
script: | |
- cd backend && npm run lint | |
needs: ["install_backend"] | |
test_frontend: | |
stage: validation | |
cache: | |
key: ${CI_COMMIT_REF_SLUG}-frontend | |
paths: | |
- frontend/node_modules/ | |
script: | |
- cd frontend && npm run test | |
needs: ["lint_frontend"] | |
test_backend: | |
stage: validation | |
cache: | |
key: ${CI_COMMIT_REF_SLUG}-backend | |
paths: | |
- backend/node_modules/ | |
script: | |
- cd backend && npm run test | |
needs: ["lint_backend"] | |
deploy_frontend: | |
image: registry.gitlab.com/passaporte.tech/passaporte.tech:latest | |
services: | |
- docker:dind | |
stage: deploy | |
only: | |
- develop | |
when: manual | |
environment: | |
name: development | |
before_script: | |
- eval $(ssh-agent -s) | |
- chmod 400 "$SSH_KEY" | |
- ssh-add "$SSH_KEY" | |
- mkdir -p ~/.ssh | |
- chmod 700 ~/.ssh | |
script: | |
- cd frontend | |
- kamal deploy | |
deploy_backend: | |
image: registry.gitlab.com/passaporte.tech/deploy-kamal-ci | |
services: | |
- docker:dind | |
stage: deploy | |
only: | |
- develop | |
when: manual | |
environment: | |
name: development | |
before_script: | |
- eval $(ssh-agent -s) | |
- chmod 400 "$SSH_KEY" | |
- ssh-add "$SSH_KEY" | |
- mkdir -p ~/.ssh | |
- chmod 700 ~/.ssh | |
script: | |
- cd backend | |
- kamal deploy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment