From cd182e3f66a789d01c819dcd9606142286d6eb57 Mon Sep 17 00:00:00 2001 From: Ornstein <6075693+SlayerOrnstein@users.noreply.github.com> Date: Tue, 14 May 2024 21:29:50 -0400 Subject: [PATCH] docs: update `DockerFile` and add a `docker-compose` example (#1476) Co-authored-by: Matej Voboril --- .dockerignore | 64 +++++++++++++++++++++++++++++++++++ .github/workflows/ci.yaml | 16 ++++++++- .github/workflows/release.yml | 30 ++++++++++++++++ Dockerfile | 18 +++++++--- docker-compose.example.yml | 15 ++++++++ 5 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.example.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..6f59ba0e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,64 @@ +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc spec coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +# PM2 Config +warframe-status.json + +# Temp file storage +tmp/ + +#nodemon dev config +.nodemon +nodemon.json +.env + +# JetBrains files +.idea/ +.run/ + +# flatcache for the items +.items +.wfinfo +.twitch +.drops +.rivens +.hy-info + +# generated files by precommit hook +.jshintrc +.jshintignore diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ad6e4564..96b37dec 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,4 +48,18 @@ jobs: uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} - + docker-image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8ee9f75..a7ddd8b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,9 @@ jobs: semantic-release: runs-on: ubuntu-latest needs: [ test ] + outputs: + new_version: ${{ steps.semantic.outputs.new_release_version }} + release: ${{ steps.release.outputs.release }} steps: - uses: actions/checkout@v4 with: @@ -42,6 +45,7 @@ jobs: node-version: '14' - name: Semantic Release uses: cycjimmy/semantic-release-action@v4 + id: semantic env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} @@ -95,3 +99,29 @@ jobs: - name: Deploy - Start Process if: ${{ steps.release.outputs.release == 'yes' }} run: ssh prod 'source ~/.zshrc && cd ~/warframe-status && pm2 start warframe-status.json' + registry-release: + needs: semantic-release + if: ${{ needs.semantic-release.outputs.release == 'yes' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/WFCD/warframe-status:latest + ghcr.io/WFCD/warframe-status:${{ needs.semantic-release.outputs.new_version }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ec4cd31b..6ce98d74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,17 @@ -FROM node:16 as build-stage +FROM node:lts-alpine as build -WORKDIR /app -COPY package*.json /app/ +COPY package*.json ./ RUN npm install + +FROM node:lts-alpine as production + +WORKDIR /app + COPY ./ /app/ -EXPOSE 3001 +COPY --from=build node_modules/ node_modules/ -ENTRYPOINT npm run start +ENV HOSTNAME=0.0.0.0 +ENV PORT=3001 + +EXPOSE 3001 +ENTRYPOINT npm start \ No newline at end of file diff --git a/docker-compose.example.yml b/docker-compose.example.yml new file mode 100644 index 00000000..40012c54 --- /dev/null +++ b/docker-compose.example.yml @@ -0,0 +1,15 @@ +services: + warframestatus: + image: warframestatus:latest + build: . # you can remove this if you plan to use your own image + # environment: + # - TWITTER_KEY= + # - TWITTER_SECRET= + # - TWITTER_BEARER_TOKEN= + # - WFINFO_FILTERED_ITEMS= + # - WFINFO_PRICES= + # - SENTRY_DSN= + # - BUILD= + # - LOG_LEVEL= + expose: + - 8080:3001 # Host port can be whatever you need it to be \ No newline at end of file