mirror of
https://github.com/Dvorinka/Trackeep.git
synced 2026-06-03 20:12:58 +00:00
5da6360ed9
Transition from a multi-service architecture to an all-in-one container by bundling PostgreSQL directly within the Docker image. This simplifies deployment, especially for environments like CasaOS, by removing the need for an external database service. - Update Dockerfile to install and configure PostgreSQL - Implement database initialization logic in docker-entrypoint.sh - Update .env.example to reflect auto-generation of credentials - Simplify docker-compose.yml to a single service - Update README.md with new deployment instructions and architecture details
60 lines
1.8 KiB
Docker
60 lines
1.8 KiB
Docker
# Multi-stage build for unified Trackeep image
|
|
# Builds both frontend and backend in one package
|
|
|
|
# Stage 1: Build Frontend
|
|
FROM node:22-alpine AS frontend-builder
|
|
WORKDIR /app/frontend
|
|
COPY frontend/package*.json ./
|
|
RUN npm install
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
# Stage 2: Build Backend
|
|
FROM golang:1.25-alpine AS backend-builder
|
|
WORKDIR /app/backend
|
|
COPY backend/go.mod backend/go.sum ./
|
|
RUN go mod download
|
|
COPY backend/ ./
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
|
|
|
|
# Stage 3: Final unified image
|
|
FROM alpine:latest
|
|
|
|
# Install dependencies including PostgreSQL
|
|
RUN apk --no-cache add ca-certificates tzdata nginx postgresql postgresql-contrib
|
|
|
|
# Create postgres user directories and fix permissions
|
|
RUN mkdir -p /var/lib/postgresql/data /run/postgresql /var/log/postgresql && \
|
|
chown -R postgres:postgres /var/lib/postgresql /run/postgresql /var/log/postgresql
|
|
|
|
# Copy backend binary and migrations
|
|
COPY --from=backend-builder /app/backend/main /app/main
|
|
COPY --from=backend-builder /app/backend/migrations /app/migrations
|
|
|
|
# Copy frontend build
|
|
COPY --from=frontend-builder /app/frontend/dist /usr/share/nginx/html
|
|
|
|
# Copy branding assets
|
|
COPY trackeep.svg /usr/share/nginx/html/
|
|
COPY trackeepfavi.png /usr/share/nginx/html/
|
|
COPY trackeepfavi_bg.png /usr/share/nginx/html/
|
|
|
|
# Copy nginx configuration
|
|
COPY frontend/nginx.conf /etc/nginx/nginx.conf
|
|
|
|
# Create directories
|
|
RUN mkdir -p /app/uploads /data /var/log/nginx
|
|
|
|
# Expose single port
|
|
EXPOSE 8080
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
|
|
|
|
# Start script to run PostgreSQL, backend and nginx
|
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
|
RUN chmod +x /docker-entrypoint.sh
|
|
|
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|