From 0e0b5386e58b3d0def22bb7d0cc7d09475c53a30 Mon Sep 17 00:00:00 2001 From: Mayank Date: Thu, 21 May 2020 14:23:37 +0530 Subject: [PATCH] stage dockerfile --- .github/workflows/on-tag.yml | 62 ++++++++++++++++++++++++++++++++++++ Dockerfile.stage | 31 ++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 .github/workflows/on-tag.yml create mode 100644 Dockerfile.stage diff --git a/.github/workflows/on-tag.yml b/.github/workflows/on-tag.yml new file mode 100644 index 0000000..d0ae6b0 --- /dev/null +++ b/.github/workflows/on-tag.yml @@ -0,0 +1,62 @@ +name: Automatically Build image on tag +env: + DOCKER_CLI_EXPERIMENTAL: enabled + TAG_FMT: '^refs/tags/(((.?[0-9]+){3,4}))$' + +on: + push: + tags: [ '*' ] + +jobs: + build: + runs-on: ubuntu-18.04 + name: Build / Push Umbrel Dashboard on version tag + steps: + - name: Setup Environment + run: | + if ! echo "$GITHUB_REF" | grep -qE "$TAG_FMT"; then + echo "ERR: TAG must be in format: vX.Y.Z or X.Y.Z or vW.X.Y.Z or W.X.Y.Z" + exit 1 + fi + VERSION="$(echo "$GITHUB_REF" | sed -E "s|$TAG_FMT|\2|")" + + TAG="$(echo "$GITHUB_REF" | sed -E "s|$TAG_FMT|\1|")" + echo ::set-env name=TAG::"$TAG" + + - name: Show set environment variables + run: | + printf " TAG: %s\n" "$TAG" + - name: Login to Docker for building + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + - name: Checkout project + uses: actions/checkout@v2 + - name: Setup Docker buildx Action + uses: crazy-max/ghaction-docker-buildx@v1 + id: buildx + with: + buildx-version: latest + qemu-version: latest + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + - name: Run Docker build X (against tag) + run: | + docker buildx build \ + --platform linux/amd64,linux/386,linux/arm/v7,linux/arm64 \ + -t getumbrel/manager:$TAG \ + --output "type=registry" \ + . + - name: Run Docker build X (against latest) + run: | + docker buildx build \ + --platform linux/amd64,linux/386,linux/arm/v7,linux/arm64 \ + -t getumbrel/manager:latest \ + --output "type=registry" \ + . + - name: Run Docker buildx (against stage) + run: | + docker buildx build \ + --platform linux/amd64 \ + -f ./Dockerfile.stage \ + -t getumbrel/manager:stage \ + --output "type=registry" \ + . \ No newline at end of file diff --git a/Dockerfile.stage b/Dockerfile.stage new file mode 100644 index 0000000..8a584bd --- /dev/null +++ b/Dockerfile.stage @@ -0,0 +1,31 @@ +FROM node:12.16.3-alpine + +# install simple http server for serving static content +RUN yarn global add http-server + +# make the 'app' folder the current working directory +WORKDIR /app + +# copy 'package.json' +COPY package.json ./ + +# copy 'yarn.lock' +COPY yarn.lock ./ + +# install dependencies +RUN yarn + +# copy project files and folders to the current working directory (i.e. 'app' folder) +COPY . . + +# Set staging env variable if building for testnet.getumbrel.com +ENV STAGING_DEPLOYMENT=true + +# build app for production +RUN yarn build + +# copy index.html to 404.html as http-server serves 404.html on all non "/" routes +RUN cp ./dist/index.html ./dist/404.html + +EXPOSE 3004 +CMD [ "http-server", "-p 3004", "dist" ] \ No newline at end of file