diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5e2bb52..d035e4c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ image: docker:20.10.5 stages: - build - push + - deploy before_script: - echo -n $CI_REGISTRY_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY @@ -39,3 +40,21 @@ push tag: - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + +deploy: + stage: deploy + tags: + - docker + environment: + name: Production + url: "$Live_Server_IP" + when: manual + before_script: + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y)' + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config' + script: + - ssh -J "$Live_Server_User"@"$Live_Server_IP" "$Live_Server_User"@"$Live_Server_Target" "echo -e 'dev:\n image: \'$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA\'\n restart: always\n ports:\n - \'8090:5000\'\n only:\n - master' > docker-compose.yml && docker-compose up -d --remove-orphans --force-recreate" \ No newline at end of file diff --git a/docker-compose.debug.yml b/docker-compose.debug.yml deleted file mode 100644 index 90432ed..0000000 --- a/docker-compose.debug.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: '3.4' - -services: - simpleblogapi: - image: simpleblogapi - build: - context: . - dockerfile: ./Dockerfile - command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 -m flask run --no-debugger --no-reload --host 0.0.0.0 --port 5000"] - ports: - - 5000:5000 - - 5678:5678 - environment: - - FLASK_APP=dev.py diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index eaf6f70..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: '3.4' - -services: - simpleblogapi: - image: simpleblogapi - build: - context: . - dockerfile: ./Dockerfile - ports: - - 5000:5000 - tty: true diff --git a/posts/2021-06-02_uncategorised_Example.md b/posts/2021-06-02_uncategorised_Example.md index 210d10b..1fcc9e4 100644 --- a/posts/2021-06-02_uncategorised_Example.md +++ b/posts/2021-06-02_uncategorised_Example.md @@ -12,4 +12,8 @@ I'm *hoping* that this works. You can also have code inline like `this`. -[Here](https://www.example.com) is a link for good measure. \ No newline at end of file +[Here](https://www.example.com) is a link for good measure. + +## Image test + +My odroid MC1 and N2 cluster \ No newline at end of file