-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (36 loc) · 1.33 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
# set global args
ARG USER=node DRONE_COMMIT_SHA=${DRONE_COMMIT_SHA} DRONE_BUILD_NUMBER=${DRONE_BUILD_NUMBER} DRONE_BUILD_LINK=${DRONE_BUILD_LINK} DRONE_COMMIT_LINK=${DRONE_COMMIT_LINK} DRONE_REPO_LINK=${DRONE_REPO_LINK} DRONE_BUILD_FINISHED=${DRONE_BUILD_FINISHED}
###########
# BUILDER #
###########
FROM node:22.11.0 AS builder
# copy build context and install dependencinpm res
WORKDIR /workspace
COPY . .
RUN yarn install
# build NuxtJS project
RUN yarn build
###########
# PROJECT #
###########
FROM node:22-slim
# pass the global args
ARG USER
ARG DRONE_COMMIT_SHA
ARG DRONE_BUILD_NUMBER
ARG DRONE_BUILD_LINK
ARG DRONE_COMMIT_LINK
ARG DRONE_REPO_LINK
ARG DRONE_BUILD_FINISHED
# copy builder output to project workdir
WORKDIR /app
COPY --from=builder --chown=${USER}:${USER} /workspace/package.json /app/
COPY --from=builder --chown=${USER}:${USER} /workspace/.output /app/.output
# set user context
USER ${USER}
# inject build args as enviroment variables
ENV NUXT_PUBLIC_BUILD_COMMIT_SHA=${DRONE_COMMIT_SHA} NUXT_PUBLIC_BUILD_NUMBER=${DRONE_BUILD_NUMBER} NUXT_PUBLIC_BUILD_LINK=${DRONE_BUILD_LINK} NUXT_PUBLIC_BUILD_COMMIT_LINK=${DRONE_COMMIT_LINK} NUXT_PUBLIC_BUILD_REPO_LINK=${DRONE_REPO_LINK} NUXT_PUBLIC_BUILD_TIMESTAMP=${DRONE_BUILD_FINISHED}
# expose port
EXPOSE ${PORT}
# run for production
CMD [ "node", "/app/.output/server/index.mjs"]