Add CI and CD
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Deploying to development."
|
||||
set -e
|
||||
set -x
|
||||
|
||||
pushd deployment
|
||||
|
||||
docker-compose -f docker-compose-frontend.yml down
|
||||
docker pull "$1"
|
||||
docker-compose -f docker-compose-frontend.yml up -d
|
||||
|
||||
popd
|
||||
|
||||
set +x
|
||||
set +e
|
||||
@@ -0,0 +1,91 @@
|
||||
stages:
|
||||
- test
|
||||
- lint
|
||||
- publish
|
||||
- deploy
|
||||
|
||||
test:unit:
|
||||
image: node:7.10.0
|
||||
stage: test
|
||||
before_script:
|
||||
- npm install
|
||||
script:
|
||||
- npm run test:unit
|
||||
|
||||
test:e2e:
|
||||
image: node:7.10.0
|
||||
stage: test
|
||||
before_script:
|
||||
- npm install
|
||||
script:
|
||||
- npm run test:e2e
|
||||
|
||||
ts:lint:
|
||||
image: node:7.10.0
|
||||
stage: lint
|
||||
before_script:
|
||||
- npm install
|
||||
script:
|
||||
- npm run lint:ts
|
||||
|
||||
sass:lint:
|
||||
image: node:7.10.0
|
||||
stage: lint
|
||||
before_script:
|
||||
- npm install
|
||||
script:
|
||||
- npm run lint:sass
|
||||
|
||||
publish:
|
||||
stage: publish
|
||||
image: docker:latest
|
||||
only:
|
||||
- develop
|
||||
before_script:
|
||||
- docker info
|
||||
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $REGISTRY_URL
|
||||
script:
|
||||
- docker build . -t "$IMAGE_NAME"
|
||||
- docker push "$IMAGE_NAME"
|
||||
|
||||
deploy_dev:
|
||||
stage: deploy
|
||||
image: alpine:latest
|
||||
environment:
|
||||
name: dev
|
||||
url: http://web.sik.party:8080
|
||||
only:
|
||||
- master
|
||||
before_script:
|
||||
- pwd
|
||||
- apk add --update openssh
|
||||
- ssh -V
|
||||
- mkdir -p ~/.ssh
|
||||
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
|
||||
script:
|
||||
- scp docker-compose-frontend.yml $DEV_SSH_USER@$DEV_SSH_HOST:~/deployment/docker-compose-frontend.yml
|
||||
- scp .deploy_dev-frontend.sh $DEV_SSH_USER@$DEV_SSH_HOST:~/deployment/deploy_dev-frontend.sh
|
||||
- ssh $DEV_SSH_USER@$DEV_SSH_HOST "bash ~/deployment/deploy_dev-frontend.sh \"$IMAGE_NAME\""
|
||||
|
||||
# deploy_production:
|
||||
# stage: deploy
|
||||
# image: alpine:latest
|
||||
# environment:
|
||||
# name: production
|
||||
# url: https://sika.sahkoinsinoorikilta.fi
|
||||
# when: manual
|
||||
# only:
|
||||
# - master
|
||||
# before_script:
|
||||
# - pwd
|
||||
# - apk add --update openssh
|
||||
# - ssh -V
|
||||
# - mkdir -p ~/.ssh
|
||||
# - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||
# - chmod 600 ~/.ssh/id_rsa
|
||||
# - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
|
||||
# script:
|
||||
# - ssh $PROD_SSH_USER@$PROD_SSH_HOST "zsh ~/deploy-frontend.sh"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
web-frontend:
|
||||
build: .
|
||||
image: git.sahkoinsinoorikilta.fi:4567/vtmk/web2.0-frontend
|
||||
command: ["bash", "-c", "cd /code && ./wait-for-it.sh db:5432 -- npm run start-prod"]
|
||||
ports:
|
||||
- "3000:8080"
|
||||
Reference in New Issue
Block a user