-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
Dockerfile
57 lines (36 loc) · 1.34 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
# build stage for building .ts files
FROM node:22-alpine as build
RUN mkdir /home/app
WORKDIR /home/app
COPY package.json .
RUN npm install --ignore-scripts
COPY . .
RUN npm run build
# prod stage for including only necessary files
FROM node:22-alpine as prod
LABEL org.opencontainers.image.source=https://github.com/ghoshRitesh12/aniwatch-api
LABEL org.opencontainers.image.description="Node.js API for obtaining anime information from hianime.to (formerly aniwatch.to)"
LABEL org.opencontainers.image.licenses=MIT
# create a non-privileged user
RUN addgroup -S aniwatch && adduser -S zoro -G aniwatch
# set secure folder permissions
RUN mkdir -p /app/public /app/dist && chown -R zoro:aniwatch /app
# set non-privileged user
USER zoro
# set working directory
WORKDIR /app
# copy config file for better use of layers
COPY --chown=zoro:aniwatch package.json .
# install dependencies
RUN npm install --omit=dev --ignore-scripts
# copy public folder from build stage to prod
COPY --from=build --chown=zoro:aniwatch /home/app/public /app/public
# copy dist folder from build stage to prod
COPY --from=build --chown=zoro:aniwatch /home/app/dist /app/dist
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s CMD [ "npm", "run", "healthcheck" ]
ENV NODE_ENV=production
ENV PORT=4000
# exposed port
EXPOSE 4000
CMD [ "node", "dist/src/server.js" ]
# exit