From 87f8c2d42b2e7d0d2344015595994e592aba3a87 Mon Sep 17 00:00:00 2001 From: Gronod Date: Fri, 15 May 2026 15:15:09 +0100 Subject: [PATCH] ci: add Dockerfile and Gitea Actions workflow for automated image builds - Dockerfile based on node:18-alpine - Gitea Actions workflow triggers on push to release/* branches - Builds and pushes to Gitea container registry with version tags --- .dockerignore | 15 ++++++++++++ .gitea/workflows/build-image.yml | 40 ++++++++++++++++++++++++++++++++ Dockerfile | 17 ++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitea/workflows/build-image.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c68e5f2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +node_modules/ +.env +.env.example +.env.sample +.git/ +.gitignore +.DS_Store +*.log +client/ +dist/ +build/ +README.md +.dockerignore +Dockerfile +.gitea/ diff --git a/.gitea/workflows/build-image.yml b/.gitea/workflows/build-image.yml new file mode 100644 index 0000000..1a23cb0 --- /dev/null +++ b/.gitea/workflows/build-image.yml @@ -0,0 +1,40 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - 'release/**' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Extract version from package.json + id: version + run: | + VERSION=$(node -p "require('./package.json').version") + BRANCH=${GITHUB_REF#refs/heads/} + RELEASE_NAME=${BRANCH#release/} + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "release=${RELEASE_NAME}" >> $GITHUB_OUTPUT + echo "Building version ${VERSION} from branch ${BRANCH}" + + - name: Login to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: git.i3omb.com + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + git.i3omb.com/gandalf/sofarr:${{ steps.version.outputs.version }} + git.i3omb.com/gandalf/sofarr:${{ steps.version.outputs.release }} + git.i3omb.com/gandalf/sofarr:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3e3a2da --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:18-alpine + +WORKDIR /app + +# Copy package files and install dependencies +COPY package.json package-lock.json ./ +RUN npm ci --omit=dev + +# Copy application source +COPY server/ ./server/ +COPY public/ ./public/ + +EXPOSE 3001 + +ENV NODE_ENV=production + +CMD ["node", "server/index.js"]