Add deploy step
This commit is contained in:
parent
5542621de7
commit
49e966ff48
@ -43,6 +43,16 @@ jobs:
|
||||
- run: docker login --username "$DOCKER_REG_USERNAME" --password "$DOCKER_REG_PASSWORD"
|
||||
- run: docker push anwinged/dayoff
|
||||
|
||||
deploy_app:
|
||||
docker:
|
||||
- image: alpine:3.10.3
|
||||
steps:
|
||||
- checkout
|
||||
- add_ssh_keys
|
||||
- run: apk add -u openssh-client
|
||||
- run: ssh-keyscan vakhrushev.me >> ~/.ssh/known_hosts
|
||||
- run: cat docker/deploy-prod | ssh dayoff@vakhrushev.me
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
test_and_build:
|
||||
@ -53,3 +63,6 @@ workflows:
|
||||
requires:
|
||||
- build_server
|
||||
- build_assets
|
||||
- deploy_app:
|
||||
requires:
|
||||
- build_docker_image
|
||||
|
32
docker/deploy-prod
Executable file
32
docker/deploy-prod
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -eux
|
||||
|
||||
source /home/dayoff/.env
|
||||
|
||||
IMAGE=anwinged/dayoff
|
||||
DATA_PATH=/home/dayoff/data
|
||||
CONTAINER_NAME="${CONTAINER_PREFIX}-server"
|
||||
|
||||
mkdir -p "$DATA_PATH"
|
||||
|
||||
TTY=
|
||||
|
||||
if [ -t 1 ] ; then
|
||||
TTY=-t
|
||||
fi
|
||||
|
||||
docker pull "${IMAGE}"
|
||||
|
||||
docker stop "${CONTAINER_NAME}" || true
|
||||
docker rm "${CONTAINER_NAME}" || true
|
||||
|
||||
docker run $TTY \
|
||||
--init \
|
||||
--detach \
|
||||
--name "${CONTAINER_NAME}" \
|
||||
--restart=unless-stopped \
|
||||
-u "$(id -u):$(id -g)" \
|
||||
-p "$WEB_SERVER_PORT:3000" \
|
||||
-v "$DATA_PATH:/opt/dayoff" \
|
||||
$IMAGE
|
Loading…
Reference in New Issue
Block a user