Add initial Docker setup with .dockerignore, Dockerfile, and entrypoint script
Some checks failed
Building and publishing Homebrewery as Docker Image / build (release) Failing after 2m10s

This commit is contained in:
Florian Weber 2025-06-24 11:31:58 +02:00
parent f99a428d67
commit 147397c4d3
Signed by: f.weber
GPG Key ID: B162B599E31221C6
4 changed files with 132 additions and 0 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
.git
node_modules
Dockerfile
README.md
*.log
homebrewery/config/*
homebrewery/.dockerignore
homebrewery/Dockerfile
homebrewery/.git
homebrewery/node_modules

View File

@ -0,0 +1,45 @@
name: Building and publishing Homebrewery as Docker Image
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-24.04
env:
TAG_NAME: ${{ github.event.release.tag_name }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
github-server-url: https://github.com
repository: naturalcrit/homebrewery.git
ref: ${{ github.event.release.tag_name }}
token: ""
path: homebrewery
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: git.morlana.online
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: |
git.morlana.online/${{ github.repository_owner }}/homebrewery:latest
git.morlana.online/${{ github.repository_owner }}/homebrewery:${{ github.event.release.tag_name }}

42
Dockerfile Normal file
View File

@ -0,0 +1,42 @@
# Base Stage for NodeJS
FROM node:22-alpine as base
ENV NODE_ENV=docker
WORKDIR /usr/src/app
# Installing dependencies with use of package-lock.json
FROM base as deps
RUN apk --no-cache add git
COPY homebrewery/package.json homebrewery/package-lock.json ./
RUN npm ci --ignore-scripts
# Build Stage
FROM base as builder
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY homebrewery/ ./
RUN npm run build
FROM base as runner
# Defining env variables for homebrewery
ENV HB_HOST=homebrewery.local.naturalcrit.com:8000 HB_NATURALCRIT_URL=local.naturalcrit.com:8010 HB_SECRET=secret PORT=8000 HB_ENABLE_V3=true HB_ENABLE_THEMES=true HB_LOCAL_ENVIRONMENTS=docker,local HB_PUBLIC_URL=https://homebrewery.naturalcrit.com
ENV HB_IMAGES=null HB_FONTS=null
# Adding tini for clean signal handling
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
# Adding Entrypoint
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Adding executables
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=deps /usr/src/app/build ./build
COPY homebrewery/ ./
EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]

35
entrypoint.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/sh
set -e
CONFIG_FILE="/usr/src/app/config/docker.json"
# Falls Verzeichnis noch nicht existiert
mkdir -p /usr/src/app/config
# Falls docker.json noch nicht existiert
if [ ! -f "$CONFIG_FILE" ]; then
echo "Creating docker.json from environment..."
cat > "$CONFIG_FILE" <<EOF
{
"host": "${HB_HOST}",
"port": ${PORT},
"naturalCritURL": "${HB_NATURALCRIT_URL}",
"secret": "${HB_SECRET}",
"enableV3": ${HB_ENABLE_V3:-false},
"enableThemes": ${HB_ENABLE_THEMES:-false},
"localEnvironments": "${HB_LOCAL_ENVIRONMENTS}",
"publicUrl": "${HB_PUBLIC_URL}",
"images": ${HB_IMAGES:-null},
"fonts": ${HB_FONTS:-null}
}
EOF
else
echo "docker.json already exists, skipping creation."
fi
# Start Homebrewery
echo "Starting Homebrewery..."
exec /tini -s -g -- node --experimental-require-module "$@" server.js