Docker Files
This commit is contained in:
30
.dockerignore
Normal file
30
.dockerignore
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Filaprint - Development and build files
|
||||||
|
node_modules
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
*.md
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Debug logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# Test files
|
||||||
|
__tests__
|
||||||
|
*.test.ts
|
||||||
|
*.spec.ts
|
||||||
|
|
||||||
|
# Build cache
|
||||||
|
.svelte-kit
|
||||||
|
.turbo
|
||||||
12
.env.example
Normal file
12
.env.example
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# MongoDB Connection
|
||||||
|
MONGODB_URI=mongodb://admin:changeme@mongodb:27017/filaprint?authSource=admin
|
||||||
|
|
||||||
|
# JWT Secret for authentication (generate a random string)
|
||||||
|
JWT_SECRET=your-super-secret-jwt-key-change-this
|
||||||
|
|
||||||
|
# MongoDB Container Credentials
|
||||||
|
MONGO_USER=admin
|
||||||
|
MONGO_PASSWORD=changeme
|
||||||
|
|
||||||
|
# Application Origin (for CSRF protection)
|
||||||
|
ORIGIN=http://localhost:3000
|
||||||
58
Dockerfile
Normal file
58
Dockerfile
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM oven/bun:1 AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package files
|
||||||
|
COPY package.json bun.lock* ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the application
|
||||||
|
RUN bun run build
|
||||||
|
|
||||||
|
# Production stage
|
||||||
|
FROM oven/bun:1-slim AS production
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package files for production dependencies
|
||||||
|
COPY package.json bun.lock* ./
|
||||||
|
|
||||||
|
# Install only production dependencies
|
||||||
|
RUN bun install --frozen-lockfile --production
|
||||||
|
|
||||||
|
# Copy built application from builder stage
|
||||||
|
COPY --from=builder /app/build ./build
|
||||||
|
COPY --from=builder /app/server ./server
|
||||||
|
|
||||||
|
# Create uploads directory for 3D models
|
||||||
|
RUN mkdir -p /app/static/uploads/models
|
||||||
|
|
||||||
|
# Copy static files
|
||||||
|
COPY --from=builder /app/static ./static
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV PORT=3000
|
||||||
|
|
||||||
|
# Expose the port
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Create a non-root user
|
||||||
|
RUN addgroup --system --gid 1001 nodejs && \
|
||||||
|
adduser --system --uid 1001 filaprint && \
|
||||||
|
chown -R filaprint:nodejs /app
|
||||||
|
|
||||||
|
USER filaprint
|
||||||
|
|
||||||
|
# Health check
|
||||||
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:3000/ || exit 1
|
||||||
|
|
||||||
|
# Start the application
|
||||||
|
CMD ["bun", "run", "start"]
|
||||||
41
docker-compose.yml
Normal file
41
docker-compose.yml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
services:
|
||||||
|
filaprint:
|
||||||
|
build: .
|
||||||
|
container_name: filaprint
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
- MONGODB_URI=${MONGODB_URI}
|
||||||
|
- JWT_SECRET=${JWT_SECRET}
|
||||||
|
- ORIGIN=${ORIGIN:-http://localhost:3000}
|
||||||
|
volumes:
|
||||||
|
# Persist uploaded 3D models
|
||||||
|
- ./data/uploads:/app/static/uploads
|
||||||
|
depends_on:
|
||||||
|
- mongodb
|
||||||
|
networks:
|
||||||
|
- filaprint-network
|
||||||
|
|
||||||
|
mongodb:
|
||||||
|
image: mongo:7
|
||||||
|
container_name: filaprint-mongo
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USER:-admin}
|
||||||
|
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-changeme}
|
||||||
|
volumes:
|
||||||
|
- mongodb_data:/data/db
|
||||||
|
networks:
|
||||||
|
- filaprint-network
|
||||||
|
# Uncomment to expose MongoDB port for debugging
|
||||||
|
# ports:
|
||||||
|
# - "27017:27017"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
filaprint-network:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mongodb_data:
|
||||||
Reference in New Issue
Block a user