diff --git a/.github/workflows/deploy-storefrontcloud.yml b/.github/workflows/deploy-storefrontcloud.yml new file mode 100644 index 0000000000..ccc4bb8f29 --- /dev/null +++ b/.github/workflows/deploy-storefrontcloud.yml @@ -0,0 +1,83 @@ +name: Deploy to Storefrontcloud +on: + push: + branches: + - master + - develop + - hotfix/v* +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v1 + - name: Setup node + uses: actions/setup-node@v1 + with: + node-version: "10.x" + - name: Build and publish docker image + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: demo-storefrontcloud-io/vue-storefront:${{ github.sha }} + registry: registry.storefrontcloud.io + username: ${{ secrets.CLOUD_USERNAME }} + password: ${{ secrets.CLOUD_PASSWORD }} + dockerfile: dev/docker/Dockerfile + buildoptions: "--compress" + deploy: + runs-on: ubuntu-latest + needs: build + steps: + - uses: chrnorm/deployment-action@releases/v1 + name: Create GitHub deployment + id: deployment + with: + token: "${{ github.token }}" + target_url: https://demo.storefrontcloud.io + environment: production + initial_status: in_progress + - name: Deploy on demo.storefrontcloud.io + if: github.ref == 'refs/heads/master' + run: | + if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"demo","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then + echo "Instance updated" + else + echo "Something went wrong during the update process..." + exit 1 + fi + - name: Deploy on next.storefrontcloud.io + if: contains(github.ref, 'hotfix/v') + run: | + if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"next","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then + echo "Instance updated" + else + echo "Something went wrong during the update process..." + exit 1 + fi + - name: Deploy on test.storefrontcloud.io + if: github.ref == 'refs/heads/develop' + run: | + if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"test","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then + echo "Instance updated" + else + echo "Something went wrong during the update process..." + exit 1 + fi + - name: Update deployment status (success) + if: success() + uses: chrnorm/deployment-status@releases/v1 + with: + token: "${{ github.token }}" + target_url: https://demo.storefrontcloud.io + state: "success" + description: Congratulations! The deploy is done. + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + - name: Update deployment status (failure) + if: failure() + uses: chrnorm/deployment-status@releases/v1 + with: + token: "${{ github.token }}" + target_url: https://demo.storefrontcloud.io + description: Unfortunately, the instance hasn't been updated. + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} \ No newline at end of file diff --git a/config/default.json b/config/default.json index f23130cdf7..7b8083e976 100644 --- a/config/default.json +++ b/config/default.json @@ -17,7 +17,7 @@ "invalidateCacheKey": "aeSu7aip", "invalidateCacheForwarding": false, "invalidateCacheForwardUrl": "http://localhost:8080/invalidate?key=aeSu7aip&tag=", - "dynamicConfigReload": false, + "dynamicConfigReload": true, "dynamicConfigContinueOnError": false, "dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage", "shipping", "boost", "query"], "dynamicConfigInclude": [], diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile new file mode 100644 index 0000000000..528a855b84 --- /dev/null +++ b/dev/docker/Dockerfile @@ -0,0 +1,17 @@ +FROM node:10 + +ENV NODE_CONFIG_ENV=docker PM2_ARGS=--no-daemon BIND_HOST=0.0.0.0 VS_ENV=prod + +WORKDIR /var/www + +COPY . . + +# Should be yarn install --production +RUN apt update && apt install -y git \ + && yarn install \ + && yarn build + +COPY dev/docker/vue-storefront.sh /usr/local/bin/ +RUN chmod a+x /usr/local/bin/vue-storefront.sh + +ENTRYPOINT ["vue-storefront.sh"] diff --git a/dev/docker/vue-storefront.sh b/dev/docker/vue-storefront.sh new file mode 100644 index 0000000000..4413dc3c06 --- /dev/null +++ b/dev/docker/vue-storefront.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +if [ "$VS_ENV" = 'dev' ]; then + yarn dev +else + yarn start +fi