Adds GitHub workflow for creating Docker images

This commit is contained in:
Shahrad Elahi 2023-09-26 05:19:23 +03:30
parent 369be994c5
commit 1ba1d58897
2 changed files with 48 additions and 4 deletions

45
.github/workflows/docker-image.yaml vendored Normal file
View File

@ -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 }}

View File

@ -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 <https://github.com/shahradelahi>"
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