mirror of
https://github.com/LogicLabs-OU/OpenArchiver.git
synced 2026-04-06 00:31:57 +02:00
This commit fixes CORS errors when running the app in Docker by introducing the `APP_URL` environment variable. A CORS policy is set up for the backend to only allow origin from the `APP_URL`. Key changes include: - New `APP_URL` and `ORIGIN` environment variables have been added to properly configure CORS and the SvelteKit adapter, making the application's public URL easily configurable. - Dockerfiles are updated to copy the entrypoint script, Drizzle config, and migration files into the final image. - Documentation and example files (`.env.example`, `docker-compose.yml`) have been updated to reflect these changes.
60 lines
2.1 KiB
Docker
60 lines
2.1 KiB
Docker
# Dockerfile for the Enterprise version of Open Archiver
|
|
|
|
ARG BASE_IMAGE=node:22-alpine
|
|
|
|
# 0. Base Stage: Define all common dependencies and setup
|
|
FROM ${BASE_IMAGE} AS base
|
|
WORKDIR /app
|
|
|
|
# Install pnpm
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
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 packages/enterprise/package.json ./packages/enterprise/
|
|
COPY apps/open-archiver-enterprise/package.json ./apps/open-archiver-enterprise/
|
|
|
|
# 1. Build Stage: Install all dependencies and build the project
|
|
FROM base AS build
|
|
COPY packages/frontend/svelte.config.js ./packages/frontend/
|
|
|
|
# Install all dependencies.
|
|
ENV PNPM_HOME="/pnpm"
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
|
|
pnpm install --shamefully-hoist --frozen-lockfile --prod=false
|
|
|
|
# Copy the rest of the source code
|
|
COPY . .
|
|
|
|
# Build the Enterprise packages.
|
|
RUN pnpm build:enterprise
|
|
|
|
# 2. Production Stage: Install only production dependencies and copy built artifacts
|
|
FROM base AS production
|
|
|
|
# Copy built application from build stage
|
|
COPY --from=build /app/packages/backend/dist ./packages/backend/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 --from=build /app/packages/frontend/build ./packages/frontend/build
|
|
COPY --from=build /app/packages/types/dist ./packages/types/dist
|
|
COPY --from=build /app/packages/enterprise/dist ./packages/enterprise/dist
|
|
COPY --from=build /app/apps/open-archiver-enterprise/dist ./apps/open-archiver-enterprise/dist
|
|
|
|
# Copy the entrypoint script and make it executable
|
|
COPY docker/docker-entrypoint.sh /usr/local/bin/
|
|
|
|
# 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:enterprise"]
|