mirror of
https://github.com/LogicLabs-OU/OpenArchiver.git
synced 2026-04-06 00:31:57 +02:00
60 lines
2.0 KiB
Docker
60 lines
2.0 KiB
Docker
# Dockerfile for Open Archiver
|
|
|
|
# 1. Build Stage: Install all dependencies and build the project
|
|
FROM node:22-alpine AS build
|
|
WORKDIR /app
|
|
|
|
# Install pnpm
|
|
RUN npm install -g pnpm
|
|
|
|
# Copy manifests and lockfile
|
|
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml* ./
|
|
COPY packages/backend/package.json ./packages/backend/
|
|
COPY packages/frontend/package.json ./packages/frontend/
|
|
COPY packages/types/package.json ./packages/types/
|
|
|
|
# Install all dependencies. Use --shamefully-hoist to create a flat node_modules structure
|
|
RUN pnpm install --shamefully-hoist --frozen-lockfile --prod=false
|
|
|
|
# Copy the rest of the source code
|
|
COPY . .
|
|
|
|
# Build packages in order.
|
|
RUN pnpm --filter @open-archiver/types build
|
|
RUN pnpm --filter @open-archiver/backend build
|
|
RUN pnpm --filter @open-archiver/frontend build
|
|
|
|
# 2. Production Stage: Install only production dependencies and copy built artifacts
|
|
FROM node:22-alpine AS production
|
|
WORKDIR /app
|
|
|
|
# Install pnpm
|
|
RUN npm install -g pnpm
|
|
|
|
# Copy manifests and lockfile
|
|
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml* ./
|
|
COPY packages/backend/package.json ./packages/backend/
|
|
COPY packages/frontend/package.json ./packages/frontend/
|
|
COPY packages/types/package.json ./packages/types/
|
|
|
|
# Copy built application from build stage
|
|
COPY --from=build /app/packages/backend/dist ./packages/backend/dist
|
|
COPY --from=build /app/packages/frontend/build ./packages/frontend/build
|
|
COPY --from=build /app/packages/types/dist ./packages/types/dist
|
|
COPY --from=build /app/packages/backend/drizzle.config.ts ./packages/backend/drizzle.config.ts
|
|
COPY --from=build /app/packages/backend/src/database/migrations ./packages/backend/src/database/migrations
|
|
|
|
# Copy the entrypoint script and make it executable
|
|
COPY docker/docker-entrypoint.sh /usr/local/bin/
|
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
|
|
# Expose the port the app runs on
|
|
EXPOSE 4000
|
|
EXPOSE 3000
|
|
|
|
# Set the entrypoint
|
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
|
|
|
# Start the application
|
|
CMD ["pnpm", "docker-start"]
|