Update dockerfile and add gitignore
This commit is contained in:
27
dockerfile
27
dockerfile
@@ -1,5 +1,5 @@
|
||||
# Use the official Bun image
|
||||
FROM oven/bun:1 AS base
|
||||
# Use the official Node.js image
|
||||
FROM node:18 AS base
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install dependencies into temp directories
|
||||
@@ -7,26 +7,26 @@ WORKDIR /usr/src/app
|
||||
FROM base AS install
|
||||
|
||||
# Install dependencies for both backend and frontend
|
||||
COPY backend/package.json backend/bun.lockb /temp/dev/backend/
|
||||
COPY frontend/package.json frontend/bun.lockb /temp/dev/frontend/
|
||||
COPY backend/package.json backend/package-lock.json /temp/dev/backend/
|
||||
COPY frontend/package.json frontend/package-lock.json /temp/dev/frontend/
|
||||
|
||||
RUN cd /temp/dev/backend && bun install
|
||||
RUN cd /temp/dev/frontend && bun install
|
||||
RUN cd /temp/dev/backend && npm install
|
||||
RUN cd /temp/dev/frontend && npm install
|
||||
|
||||
# Install with --production (exclude devDependencies)
|
||||
RUN mkdir -p /temp/prod/backend /temp/prod/frontend
|
||||
COPY backend/package.json backend/bun.lockb /temp/prod/backend/
|
||||
COPY frontend/package.json frontend/bun.lockb /temp/prod/frontend/
|
||||
COPY backend/package.json backend/package-lock.json /temp/prod/backend/
|
||||
COPY frontend/package.json frontend/package-lock.json /temp/prod/frontend/
|
||||
|
||||
RUN cd /temp/prod/backend && bun install
|
||||
RUN cd /temp/prod/frontend && bun install
|
||||
RUN cd /temp/prod/backend && npm install --production
|
||||
RUN cd /temp/prod/frontend && npm install --production
|
||||
|
||||
# Build the frontend project
|
||||
FROM install AS build-frontend
|
||||
WORKDIR /usr/src/app/frontend
|
||||
COPY --from=install /temp/dev/frontend/node_modules node_modules
|
||||
COPY frontend/ .
|
||||
RUN bun run build
|
||||
RUN npm run build
|
||||
|
||||
# Prepare for final release
|
||||
FROM base AS release
|
||||
@@ -43,6 +43,7 @@ COPY backend/ backend/
|
||||
COPY --from=build-frontend /usr/src/app/frontend/dist backend/public
|
||||
|
||||
# Set the entrypoint to run the backend server
|
||||
USER bun
|
||||
USER node
|
||||
WORKDIR /usr/src/app/backend
|
||||
EXPOSE 3000/tcp
|
||||
ENTRYPOINT [ "bun", "run", "backend/src/server.ts" ]
|
||||
ENTRYPOINT [ "npm", "run", "start"]
|
||||
|
Reference in New Issue
Block a user