-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
72 lines (59 loc) · 2.2 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
61
62
63
64
65
66
67
68
69
70
71
72
# set global args
ARG DSP_API_URL PORT=3000 USER=node HOST=0.0.0.0 MATOMO_SITE_ID TARGET_ENV 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} DEBUG='false' ONION_ADDRESS
###########
# BUILDER #
###########
FROM node:16-alpine3.14 AS builder
# pass the global args
ARG DSP_API_URL
ARG HOST
ARG PORT
ARG MATOMO_SITE_ID
ARG TARGET_ENV
ARG DRONE_COMMIT_SHA
ARG DRONE_BUILD_NUMBER
ARG DRONE_BUILD_LINK
ARG DRONE_COMMIT_LINK
ARG DRONE_REPO_LINK
ARG DRONE_BUILD_FINISHED
ARG DEBUG
ARG ONION_ADDRESS
# Create app directory
WORKDIR /workspace
COPY . .
RUN npm install
# Inject the enviromental variables
ENV DSP_API_URL=$DSP_API_URL HOST=$HOST PORT=$PORT MATOMO_SITE_ID=$MATOMO_SITE_ID TARGET_ENV=${TARGET_ENV} 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} DEBUG=${DEBUG} ONION_ADDRESS=${ONION_ADDRESS}
# Build NuxtJS project
RUN npm run build
###########
# PROJECT #
###########
FROM node:16-slim
# pass the global args
ARG DSP_API_URL
ARG HOST
ARG PORT
ARG USER
ARG MATOMO_SITE_ID
ARG TARGET_ENV
ARG DRONE_COMMIT_SHA
ARG DRONE_BUILD_NUMBER
ARG DRONE_BUILD_LINK
ARG DRONE_COMMIT_LINK
ARG DRONE_REPO_LINK
ARG DRONE_BUILD_FINISHED
ARG DEBUG
ARG ONION_ADDRESS
# copy builder output to project workdir
WORKDIR /app
COPY --from=builder --chown=${USER}:${USER} /workspace/ /app/
COPY --from=builder --chown=${USER}:${USER} /workspace/.nuxt /app/.nuxt
# Inject the enviromental variables
ENV DSP_API_URL=$DSP_API_URL PORT=$PORT HOST=$HOST MATOMO_SITE_ID=$MATOMO_SITE_ID TARGET_ENV=${TARGET_ENV} 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} DEBUG=${DEBUG} ONION_ADDRESS=${ONION_ADDRESS}
# set user context
USER ${USER}
# expose port
EXPOSE ${PORT}
# start command
CMD [ "npm", "run", "start"]