f
This commit is contained in:
parent
ecf2dcf569
commit
eaa4d1c23b
@ -1,25 +1,6 @@
|
|||||||
stages:
|
stages:
|
||||||
- build
|
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
variables:
|
|
||||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
|
|
||||||
IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
|
|
||||||
|
|
||||||
build_and_push:
|
|
||||||
stage: build
|
|
||||||
image: docker:29
|
|
||||||
variables:
|
|
||||||
DOCKER_HOST: unix:///var/run/docker.sock
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
||||||
script:
|
|
||||||
- test -n "$CI_REGISTRY" -a -n "$CI_REGISTRY_IMAGE" || (echo "GitLab Container Registry is not enabled/configured for this project." && exit 1)
|
|
||||||
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
|
|
||||||
- docker build --target production -t "$IMAGE_TAG" -t "$IMAGE_TAG_LATEST" .
|
|
||||||
- docker push "$IMAGE_TAG"
|
|
||||||
- docker push "$IMAGE_TAG_LATEST"
|
|
||||||
|
|
||||||
deploy_production:
|
deploy_production:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
image: alpine:3.20
|
image: alpine:3.20
|
||||||
@ -46,7 +27,4 @@ deploy_production:
|
|||||||
--exclude='coverage' \
|
--exclude='coverage' \
|
||||||
--exclude='dist' \
|
--exclude='dist' \
|
||||||
./ "$DEPLOY_USER@$DEPLOY_HOST:/opt/apps/api-finance/"
|
./ "$DEPLOY_USER@$DEPLOY_HOST:/opt/apps/api-finance/"
|
||||||
- test -n "$CI_REGISTRY" -a -n "$CI_REGISTRY_IMAGE" || (echo "GitLab Container Registry is not enabled/configured for this project." && exit 1)
|
- ssh "$DEPLOY_USER@$DEPLOY_HOST" "cd /opt/apps/api-finance && docker compose -f docker-compose.server.yml up -d --build"
|
||||||
- ssh "$DEPLOY_USER@$DEPLOY_HOST" "echo '$CI_REGISTRY_PASSWORD' | docker login -u '$CI_REGISTRY_USER' --password-stdin '$CI_REGISTRY'"
|
|
||||||
- ssh "$DEPLOY_USER@$DEPLOY_HOST" "cd /opt/apps/api-finance && APP_IMAGE='$IMAGE_TAG' docker compose -f docker-compose.server.yml pull"
|
|
||||||
- ssh "$DEPLOY_USER@$DEPLOY_HOST" "cd /opt/apps/api-finance && APP_IMAGE='$IMAGE_TAG' docker compose -f docker-compose.server.yml up -d"
|
|
||||||
|
|||||||
@ -21,7 +21,10 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
app:
|
app:
|
||||||
image: ${APP_IMAGE}
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
target: production
|
||||||
container_name: api_finance_app
|
container_name: api_finance_app
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user