first commit
This commit is contained in:
46
Dockerfile
Normal file
46
Dockerfile
Normal file
@@ -0,0 +1,46 @@
|
||||
# Stage 1: Build frontend
|
||||
FROM node:22-alpine AS frontend-builder
|
||||
WORKDIR /app/frontend
|
||||
COPY frontend/package.json frontend/yarn.lock* ./
|
||||
RUN yarn install --frozen-lockfile || yarn install
|
||||
COPY frontend/ ./
|
||||
RUN yarn build
|
||||
|
||||
# Stage 2: Build backend
|
||||
FROM node:22-alpine AS backend-builder
|
||||
WORKDIR /app/backend
|
||||
COPY backend/package.json backend/yarn.lock* ./
|
||||
RUN yarn install --frozen-lockfile || yarn install
|
||||
COPY backend/ ./
|
||||
RUN yarn db:generate && yarn build
|
||||
|
||||
# Stage 3: Production
|
||||
FROM node:22-alpine AS production
|
||||
WORKDIR /app
|
||||
|
||||
# Install production dependencies only
|
||||
COPY backend/package.json backend/yarn.lock* ./
|
||||
RUN yarn install --production --frozen-lockfile || yarn install --production
|
||||
|
||||
# Copy Prisma schema and generate client
|
||||
COPY backend/prisma ./prisma
|
||||
RUN npx prisma generate
|
||||
|
||||
# Copy built backend
|
||||
COPY --from=backend-builder /app/backend/dist ./dist
|
||||
|
||||
# Copy built frontend
|
||||
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
|
||||
|
||||
# Create data directory for SQLite
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV DATABASE_URL="file:/app/data/timetracker.db"
|
||||
ENV STATIC_ROOT="/app/frontend/dist"
|
||||
ENV PORT=3000
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# Initialize database and start server
|
||||
CMD npx prisma db push --skip-generate && node dist/index.js
|
||||
Reference in New Issue
Block a user