From 1ba1d588979a5c5d4ae90e589e81585741e705fb Mon Sep 17 00:00:00 2001 From: Shahrad Elahi Date: Tue, 26 Sep 2023 05:19:23 +0330 Subject: [PATCH] Adds GitHub workflow for creating Docker images --- .github/workflows/docker-image.yaml | 45 +++++++++++++++++++++++++++++ Dockerfile | 7 ++--- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/docker-image.yaml diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/docker-image.yaml new file mode 100644 index 0000000..c2d9a7c --- /dev/null +++ b/.github/workflows/docker-image.yaml @@ -0,0 +1,45 @@ +name: Build Docker Image + +on: + push: + branches: + - "master" + tags: + - "v*.*.*" + +env: + IMAGE_NAME: shahradelahi/wireadmin + # By default, image tag is the commit SHA + IMAGE_TAG: ${{ github.sha }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.PRIVATE_TOKEN }} + + # if it was a release tag, use the tag as the image tag + - name: Set image tag + if: startsWith(github.ref, 'refs/tags/v') + run: | + echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + echo "IMAGE_TAG=${IMAGE_TAG//./-}" >> $GITHUB_ENV + + - name: Push to GitHub Container Registry + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} diff --git a/Dockerfile b/Dockerfile index 179ec87..0709edb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ RUN apk add -U --no-cache \ FROM node:alpine as builder WORKDIR /app -COPY package.json package-lock.json ./ +COPY /src/package.json /src/package-lock.json ./ RUN npm install ENV NODE_ENV=production @@ -37,13 +37,12 @@ LABEL Maintainer="Shahrad Elahi " COPY /config/torrc /etc/tor/torrc -COPY --from=builder /app/.build ./.build COPY --from=builder /app/.next ./.next COPY --from=builder /app/next.config.js ./next.config.js COPY --from=builder /app/public ./public -COPY package.json package-lock.json ./ -RUN npm install +COPY /src/package.json /src/package-lock.json ./ +RUN npm install --omit dev EXPOSE 3000/tcp