forked from platformatic/platformatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (42 loc) · 1.25 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
54
55
56
57
58
59
60
FROM node:20-alpine as base
ENV HOME=/home
ENV PLT_HOME=$HOME/platformatic/
ENV PNPM_HOME=$HOME/pnpm
ENV APP_HOME=$HOME/app
ENV PATH=/home/pnpm:$PATH
RUN mkdir $PNPM_HOME
# Install Platformatic in the $PLT_HOME folder
WORKDIR $PLT_HOME
# Install required packages
RUN apk update && apk add --no-cache python3 libc-dev make g++
# Install pnpm
RUN npm i pnpm@9 --location=global
# Copy lock files
COPY package.json ./
COPY pnpm-lock.yaml ./
COPY pnpm-workspace.yaml ./
# Fetch all dependencies
RUN pnpm fetch --prod --frozen-lockfile
# Copy files
COPY . .
# Install all the deps in the source code
RUN pnpm install --prod --offline --node-linker=hoisted
# Add platformatic to path
RUN cd packages/cli && pnpm link --global
# No pnpm/build tools install here, we just copy the files from the previous stage
FROM node:20-alpine
# We don't need the build tools anymore
RUN apk update && apk add --no-cache dumb-init
ENV HOME=/home
ENV APP_HOME=$HOME/app
ENV PLT_HOME=$HOME/platformatic/
COPY --from=base $PLT_HOME $PLT_HOME
# Add platformatic to path
RUN cd $PLT_HOME/packages/cli && npm link
# Move to the app directory
WORKDIR $APP_HOME
# Reduce our permissions from root to a normal user
RUN chown node:node .
USER node
ENTRYPOINT ["dumb-init"]
CMD ["platformatic"]