From 2384d54107b3c607c0a53f85fc63a0b1dff1feb0 Mon Sep 17 00:00:00 2001 From: Refringe Date: Sat, 7 Dec 2024 13:15:03 -0500 Subject: [PATCH] Issue with dockerfile build stages --- Dockerfile | 30 +++++++++++++++--------------- README.md | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index aab73f5..4ec0fba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20.12-slim AS base +FROM node:20.12-slim # Update and install dependencies RUN apt-get update && apt-get install -y curl unzip && rm -rf /var/lib/apt/lists/* @@ -8,27 +8,27 @@ RUN curl -fsSL https://bun.sh/install | bash ENV BUN_INSTALL="/root/.bun" ENV PATH="$BUN_INSTALL/bin:$PATH" -# Frontend build stage -FROM base AS frontend-build +# Set up working directory +WORKDIR /app + +# Copy and build frontend +COPY frontend ./frontend WORKDIR /app/frontend -COPY frontend . RUN npm install RUN npm run build:prod -# Copy built frontend into backend public directory -FROM base AS backend-build -WORKDIR /app/api -RUN mkdir -p /app/api/public -COPY --from=frontend-build /app/frontend/dist/* /app/api/public/ +# Move built frontend assets into backend public directory +WORKDIR /app +RUN mkdir -p ./api/public +RUN cp -r ./frontend/dist/* ./api/public/ -# Backend build stage -COPY api . +# Copy and build backend +COPY api ./api +WORKDIR /app/api RUN cp .env.example .env RUN bun install -# Final image -FROM base +# Final setup WORKDIR /app/api -COPY --from=backend-build /app/api . EXPOSE 3001 -CMD ["bun", "run", "start"] +CMD ["bun", "run", "start"] \ No newline at end of file diff --git a/README.md b/README.md index 7c14f38..2b6629f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ https://db.sp-tarkov.com ## Run Docker Image - `docker pull ghcr.io/sp-tarkov/db-website:main` -- `docker run -p 3001:3001 db-website:main` +- `docker run -p 3001:3001 ghcr.io/sp-tarkov/db-website:main` ## Local Build