Skip to content

Instantly share code, notes, and snippets.

@evilj0e
Last active March 9, 2023 21:26
Show Gist options
  • Save evilj0e/66a550359ec3b11fe9f95c9d16c9a29f to your computer and use it in GitHub Desktop.
Save evilj0e/66a550359ec3b11fe9f95c9d16c9a29f to your computer and use it in GitHub Desktop.
image: gitlab/dind
stages:
- build
- deploy
build:
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker run -v ${PWD}:/work fpco/stack-build bash -c 'cd /work && stack setup && stack install && /root/.local/bin/blog build'
- docker build -t registry.gitlab.com/<you>/<image name> .
- docker push registry.gitlab.com/<you>/<image name>
deploy:
stage: deploy
environment: production
script:
- apt-get update -y && apt-get install sshpass -y
- chmod -x ./deploy.sh
- sh ./deploy.sh $PASS $CI_BUILD_TOKEN
sshpass -p $1 ssh -o StrictHostKeyChecking=no root@x.x.x.x << ENDSSH
docker login -u gitlab-ci-token -p $2 registry.gitlab.com
docker stop <image name>
docker rm <image name>
docker pull registry.gitlab.com/<you>/<image name>
docker run --name <image name> -p 80:80 -d registry.gitlab.com/<you>/<image name>
ENDSSH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment