forked from ianlucas/cs2-inventory-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
49 lines (37 loc) · 1.27 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Adapted from Remix's Indie Stack
FROM node:20-bullseye-slim AS base
ENV NODE_ENV=production
# Install system dependencies
RUN apt-get update && apt-get install -y openssl git
# Install dependencies
FROM base AS deps
WORKDIR /myapp
COPY package.json package-lock.json ./
RUN npm ci --include=dev
# Generate Prisma client, add commit hash, and build the app
FROM deps AS build
ARG SOURCE_COMMIT
ENV SOURCE_COMMIT=${SOURCE_COMMIT}
COPY prisma ./prisma
RUN npx prisma generate
COPY . .
RUN if [ -d .git ]; then \
git log -n 1 --pretty=format:%H > .build-last-commit; \
elif [ -n "${SOURCE_COMMIT:-}" ] && [ "${SOURCE_COMMIT:-}" != "unknown" ]; then \
echo "${SOURCE_COMMIT:-}" > .build-last-commit; \
else \
touch .build-last-commit; \
fi
RUN npm run build
RUN rm -rf .git
# Production image with minimal footprint
FROM base
WORKDIR /myapp
COPY --from=deps /myapp/node_modules /myapp/node_modules
COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma
COPY --from=build /myapp/build /myapp/build
COPY --from=build /myapp/public /myapp/public
COPY --from=build /myapp/package.json /myapp/package.json
COPY --from=build /myapp/start.sh /myapp/.build-last-commit /myapp
COPY --from=build /myapp/prisma /myapp/prisma
ENTRYPOINT [ "./start.sh" ]