mirror of
https://github.com/Vale54321/schafkop-neu.git
synced 2025-12-13 02:29:33 +01:00
feat: update Docker configuration for combined frontend and backend build process
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
|
yarn-error.log
|
||||||
node_modules
|
node_modules
|
||||||
**/node_modules
|
**/node_modules
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
dist
|
|
||||||
tmp
|
tmp
|
||||||
temp
|
temp
|
||||||
.git
|
.git
|
||||||
.gitignore
|
.gitignore
|
||||||
Dockerfile*
|
|
||||||
frontend/dist
|
|
||||||
backend/coverage
|
backend/coverage
|
||||||
|
# Keep built frontend out of context cache noise but allow source
|
||||||
|
frontend/dist
|
||||||
|
|||||||
10
.github/workflows/BuildAndPushContainer.yml
vendored
10
.github/workflows/BuildAndPushContainer.yml
vendored
@@ -8,7 +8,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ${{ github.repository }}/backend
|
IMAGE_NAME: ${{ github.repository }}/app
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
@@ -47,12 +47,16 @@ jobs:
|
|||||||
- name: Build and push Docker image (multi-arch)
|
- name: Build and push Docker image (multi-arch)
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ./frontend
|
context: .
|
||||||
file: ./frontend/Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
build-args: |
|
||||||
|
NODE_VERSION=20-bookworm-slim
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Notify updater (GET, bearer)
|
- name: Notify updater (GET, bearer)
|
||||||
if: ${{ success() && github.ref == 'refs/heads/main' }}
|
if: ${{ success() && github.ref == 'refs/heads/main' }}
|
||||||
|
|||||||
46
Dockerfile
Normal file
46
Dockerfile
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
######## Root Combined Frontend + Backend Build ########
|
||||||
|
## Build args (can be overridden)
|
||||||
|
ARG NODE_VERSION=20-bookworm-slim
|
||||||
|
|
||||||
|
########################
|
||||||
|
# 1) Frontend build #
|
||||||
|
########################
|
||||||
|
FROM node:${NODE_VERSION} AS frontend-build
|
||||||
|
WORKDIR /frontend
|
||||||
|
COPY frontend/package*.json ./
|
||||||
|
RUN npm install --no-audit --no-fund
|
||||||
|
COPY frontend/ .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
########################
|
||||||
|
# 2) Backend build #
|
||||||
|
########################
|
||||||
|
FROM node:${NODE_VERSION} AS backend-build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY backend/package*.json ./
|
||||||
|
RUN npm install --no-audit --no-fund
|
||||||
|
COPY backend/ .
|
||||||
|
# Copy built frontend assets
|
||||||
|
COPY --from=frontend-build /frontend/dist ./public
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
########################
|
||||||
|
# 3) Production image #
|
||||||
|
########################
|
||||||
|
FROM node:${NODE_VERSION} AS runner
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install production deps
|
||||||
|
COPY backend/package*.json ./
|
||||||
|
RUN npm install --omit=dev --no-audit --no-fund
|
||||||
|
|
||||||
|
# Copy backend dist + public
|
||||||
|
COPY --from=backend-build /app/dist ./dist
|
||||||
|
COPY --from=backend-build /app/public ./public
|
||||||
|
|
||||||
|
ENV PORT=3000 \
|
||||||
|
SERIAL_BAUD=115200
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["node", "dist/main.js"]
|
||||||
@@ -2,7 +2,7 @@ services:
|
|||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: frontend/Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: schafkop-app
|
container_name: schafkop-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user