forked from tcgdex/cards-database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
53 lines (39 loc) · 1.28 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
50
51
52
53
FROM docker.io/oven/bun:1-alpine AS build
# go to work folder
WORKDIR /usr/src/app
# Add git as it is used to fetch updated times
RUN apk add git &&\
git config --global safe.directory '*'
ADD --chown=bun:bun package.json bun.lockb ./
ADD --chown=bun:bun server/package.json server/bun.lockb ./server/
# install dependencies
RUN bun install --frozen-lockfile && \
cd server && \
bun install --frozen-lockfile
# Add project files
ADD --chown=bun:bun . .
# build
RUN cd server && \
bun run compile
# remove dev dependencies (bun do not yet support "prune")
RUN cd server && \
rm -rf node_modules && \
bun install --frozen-install --production
# go to another VM
FROM docker.io/oven/bun:1-alpine AS prod
# inform software to be in production
ENV NODE_ENV=production
# run as non root user
USER bun
# go to work folder
WORKDIR /usr/src/app
# copy from build image
COPY --chown=bun:bun --from=build /usr/src/app/server/generated ./generated
COPY --chown=bun:bun --from=build /usr/src/app/server/node_modules ./node_modules
COPY --chown=bun:bun --from=build /usr/src/app/server/src ./src
COPY --chown=bun:bun --from=build /usr/src/app/server/public ./public
COPY --chown=bun:bun --from=build /usr/src/app/server/package.json ./package.json
# Expose port
EXPOSE 3000
# run it !
CMD ["bun", "run", "start"]