updated Docker and docker-compose files

This commit is contained in:
2025-12-26 08:45:47 +01:00
parent 06788abe49
commit 2697aee592
8 changed files with 82 additions and 34 deletions
-6
View File
@@ -1,6 +0,0 @@
FROM node:21.6-alpine
WORKDIR /vue_app
expose 8080
CMD ["npm", "run", "serve"]
+16 -2
View File
@@ -1,5 +1,5 @@
# =========== 1) Build stage =========== # =========== 1) Build stage ===========
FROM golang:1.24-alpine AS builder FROM golang:1.25-alpine AS builder
# Install necessary packages for CGO and SQLite # Install necessary packages for CGO and SQLite
RUN apk add --no-cache gcc musl-dev sqlite-dev RUN apk add --no-cache gcc musl-dev sqlite-dev
@@ -17,7 +17,21 @@ COPY . .
RUN go build -v -o server cmd/main.go RUN go build -v -o server cmd/main.go
# =========== 2) Runtime stage =========== # =========== 2) Runtime stage ===========
FROM alpine:3.18 FROM alpine:3.23
# Install Chromium for PDF rendering
RUN apk add --no-cache \
chromium \
chromium-chromedriver \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont
# Set Chrome path for chromedp
ENV CHROME_BIN=/usr/bin/chromium-browser \
CHROME_PATH=/usr/bin/chromium-browser
WORKDIR /app WORKDIR /app
+5 -3
View File
@@ -1,10 +1,12 @@
# =========== 1) Build stage =========== # =========== 1) Build stage ===========
FROM node:18-alpine AS build FROM node:22-alpine AS build
WORKDIR /usr/src/app WORKDIR /usr/src/app
# Copy package manifests and install dependencies # Copy package files
COPY package*.json ./ COPY package*.json ./
# Install dependencies
RUN npm install RUN npm install
# Copy the rest of the frontend code # Copy the rest of the frontend code
@@ -19,7 +21,7 @@ FROM nginx:alpine
# Copy production build to Nginx html folder. # Copy production build to Nginx html folder.
# Adjust /usr/src/app/build -> /usr/src/app/dist if youre using Angular/Vue # Adjust /usr/src/app/build -> /usr/src/app/dist if youre using Angular/Vue
#COPY --from=build /usr/src/app/build /usr/share/nginx/html #COPY --from=build /usr/src/app/build /usr/share/nginx/html
COPY --from=build /usr/src/app /usr/share/nginx/html COPY --from=build /usr/src/app/dist /usr/share/nginx/html
# Expose HTTP port # Expose HTTP port
EXPOSE 80 EXPOSE 80
+1 -1
View File
@@ -1,5 +1,5 @@
# Development Dockerfile für Vue.js Frontend # Development Dockerfile für Vue.js Frontend
FROM node:18-alpine FROM node:22-alpine
WORKDIR /app WORKDIR /app
+6 -6
View File
@@ -7,9 +7,6 @@ services:
container_name: bamort-backend-dev container_name: bamort-backend-dev
ports: ports:
- "8180:8180" - "8180:8180"
volumes:
- ../backend:/app
- go-mod-cache:/go/pkg/mod
environment: environment:
- GO_ENV=development - GO_ENV=development
- CGO_ENABLED=1 - CGO_ENABLED=1
@@ -21,6 +18,9 @@ services:
working_dir: /app working_dir: /app
# Restart if Go code changes cause crash # Restart if Go code changes cause crash
restart: unless-stopped restart: unless-stopped
volumes:
- ../backend:/app
- go-mod-cache:/go/pkg/mod
frontend-dev: frontend-dev:
build: build:
@@ -29,15 +29,15 @@ services:
container_name: bamort-frontend-dev container_name: bamort-frontend-dev
ports: ports:
- "5173:5173" # Vite dev server port - "5173:5173" # Vite dev server port
volumes:
- ../frontend:/app
- /app/node_modules # Prevent overwriting node_modules
environment: environment:
- NODE_ENV=development - NODE_ENV=development
- VITE_API_URL=${VITE_API_URL:-http://192.168.0.48:8180} - VITE_API_URL=${VITE_API_URL:-http://192.168.0.48:8180}
depends_on: depends_on:
- backend-dev - backend-dev
restart: unless-stopped restart: unless-stopped
volumes:
- ../frontend:/app
- /app/node_modules # Prevent overwriting node_modules
mariadb: mariadb:
image: mariadb:11.4 image: mariadb:11.4
+21 -16
View File
@@ -1,37 +1,42 @@
version: "3.8" version: "3.8"
services: services:
backend: backend:
build: build:
context: ../backend context: ../backend
dockerfile: ../docker/Dockerfile dockerfile: ../docker/Dockerfile.backend
container_name: backend container_name: bamort-backend
environment:
- DATABASE_TYPE=mysql
- DATABASE_URL=bamort:${MARIADB_PASSWORD:-secure_user_password}@tcp(mariadb:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local
ports: ports:
- "8180:8180" - "8180:8180"
environment:
- GO_ENV=production
- CGO_ENABLED=1
- DATABASE_TYPE=mysql
- DATABASE_URL=bamort:${MARIADB_PASSWORD:-secure_user_password}@tcp(mariadb:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local
depends_on: depends_on:
mariadb: mariadb:
condition: service_healthy condition: service_healthy
working_dir: /app
restart: unless-stopped restart: unless-stopped
frontend: frontend:
build: build:
context: ../frontend context: ../frontend
dockerfile: ../docker/Dockerfile.frontend dockerfile: ../docker/Dockerfile.frontend
container_name: frontend container_name: bamort-frontend
ports: ports:
- "5173:80" - "5173:80"
environment: environment:
- VITE_API_URL=${VITE_API_URL:-http://bamort.trokan.de:8180}
- BASE_URL=http://bamort.trokan.de:8180
- PORT=8180
- ENVIRONMENT=production - ENVIRONMENT=production
- DATABASE_TYPE=mysql - VITE_API_URL=${VITE_API_URL:-http://bamort.trokan.de:8180}
- DATABASE_URL=bamort:bG4)efozrc@tcp(mariadb:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local - BASE_URL=http://bamort.trokan.de
- PORT=8180
depends_on: depends_on:
- backend - backend
restart: unless-stopped
mariadb: mariadb:
image: mariadb:11.4 image: mariadb:11.4
@@ -51,8 +56,8 @@ services:
- ./init-db:/docker-entrypoint-initdb.d - ./init-db:/docker-entrypoint-initdb.d
healthcheck: healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
start_period: 10s start_period: 30s
timeout: 5s timeout: 15s
retries: 3 retries: 3
# phpMyAdmin - Database Management (commented out for production) # phpMyAdmin - Database Management (commented out for production)
@@ -74,5 +79,5 @@ services:
# mariadb: # mariadb:
# condition: service_healthy # condition: service_healthy
volumes: #volumes:
db_data: # db_data:
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
echo "🚀 Starting Bamort Development Environment..."
# Prüfe ob Docker läuft
if ! docker info > /dev/null 2>&1; then
echo "❌ Docker ist nicht gestartet. Bitte starte Docker zuerst."
exit 1
fi
# Gehe ins Docker-Verzeichnis
cd "$(dirname "$0")"
echo "📦 Building and starting development containers..."
# Stoppe vorhandene Container
docker-compose -f docker-compose.yml down
# Baue und starte die Container
docker-compose -f docker-compose.yml up --build
echo "✅ Development environment stopped."
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
echo "🛑 Stopping Bamort Development Environment..."
# Gehe ins Docker-Verzeichnis
cd "$(dirname "$0")"
# Stoppe und entferne Container
docker-compose -f docker-compose.yml down
echo "✅ Development environment stopped."