From bc7b5fc6c99888429e0e0b179482ae9f6a9abbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 9 Apr 2020 11:00:30 +0200 Subject: [PATCH] Setting up continuous deployment --- .github/workflows/build-and-deploy.yml | 65 ++++++++++++++++++++++++++ back/.dockerignore | 4 ++ back/Dockerfile | 8 ++++ deeployer.json | 19 ++++++++ front/.dockerignore | 3 ++ front/Dockerfile | 9 ++++ 6 files changed, 108 insertions(+) create mode 100644 .github/workflows/build-and-deploy.yml create mode 100644 back/.dockerignore create mode 100644 back/Dockerfile create mode 100644 deeployer.json create mode 100644 front/.dockerignore create mode 100644 front/Dockerfile diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 00000000..ec7d3c69 --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,65 @@ +name: Build, push and deploy Docker image + +on: + push: + branches: + - master + - cd +# tags: +# - '*' + +# Enables BuildKit +env: + DOCKER_BUILDKIT: 1 + +jobs: + + build-front: + + runs-on: ubuntu-latest + + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: "Build and push front image" + uses: docker/build-push-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: thecodingmachine/workadventure-front + tag_with_ref: true + add_git_labels: true + working-directory: "front" + + build-back: + + runs-on: ubuntu-latest + + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: "Build and push back image" + uses: docker/build-push-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: thecodingmachine/workadventure-back + tag_with_ref: true + add_git_labels: true + working-directory: "back" + + deeploy: + needs: + - build-front + - build-back + runs-on: ubuntu-latest + + - name: Checkout + uses: actions/checkout@v2 + + - name: "Deploy" + uses: thecodingmachine/deeployer@master diff --git a/back/.dockerignore b/back/.dockerignore new file mode 100644 index 00000000..ca0a17d7 --- /dev/null +++ b/back/.dockerignore @@ -0,0 +1,4 @@ +/dist/ +/node_modules/ +/dist/bundle.js +/yarn-error.log diff --git a/back/Dockerfile b/back/Dockerfile new file mode 100644 index 00000000..edaeee6a --- /dev/null +++ b/back/Dockerfile @@ -0,0 +1,8 @@ +FROM thecodingmachine/nodejs:12 + +COPY . . +RUN yarn install + +ENV NODE_ENV=production + +CMD ['yarn', 'run', 'prod'] diff --git a/deeployer.json b/deeployer.json new file mode 100644 index 00000000..2eaeeba0 --- /dev/null +++ b/deeployer.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://raw.githubusercontent.com/thecodingmachine/deeployer/master/deeployer.schema.json", + "containers": { + "back": { + "image": "", + "host": "http://api.workadventure.test.thecodingmachine.com", + "env": { + "SECRET_KEY": "tempSecretKeyNeedsToChange" + } + }, + "front": { + "image": "", + "host": "http://workadventure.test.thecodingmachine.com", + "env": { + "API_URL": "http://api.workadventure.test.thecodingmachine.com" + } + } + } +} diff --git a/front/.dockerignore b/front/.dockerignore new file mode 100644 index 00000000..048e02ca --- /dev/null +++ b/front/.dockerignore @@ -0,0 +1,3 @@ +/node_modules/ +/dist/bundle.js +/yarn-error.log diff --git a/front/Dockerfile b/front/Dockerfile new file mode 100644 index 00000000..4ab4f273 --- /dev/null +++ b/front/Dockerfile @@ -0,0 +1,9 @@ +# we are rebuilding on each deploy to cope with the API_URL environment URL +FROM thecodingmachine/nodejs:12-apache + +COPY . . +RUN yarn install + +ENV NODE_ENV=production +ENV STARTUP_COMMAND_1="yarn run build" +ENV APACHE_DOCUMENT_ROOT=dist/