-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
228 lines (137 loc) · 4.84 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#############
# Create base image.
FROM node:22.12.0-alpine AS base-image
# # The `CI` environment variable must be set for pnpm to run in headless mode
# ENV CI=true
WORKDIR /srv/app/
RUN apk update \
&& apk add --no-cache git \
&& corepack enable
#############
# Development container image.
FROM base-image AS development
# COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# VOLUME /srv/.pnpm-store
VOLUME /srv/app
USER node
# ENTRYPOINT ["docker-entrypoint.sh"]
# CMD ["pnpm", "run", "--dir", "src", "dev", "--host"]
CMD ["npm", "run", "dev", "--port", "3000"]
EXPOSE 3000
# HEALTHCHECK --interval=10s CMD wget -O /dev/null http://localhost:3000/api/healthcheck || exit 1
########################
# Prepare ci.
FROM base-image AS prepare
# COPY ./pnpm-lock.yaml ./
COPY ./package.json ./package-lock.json ./
# RUN pnpm fetch
RUN npm install
COPY ./ ./
# RUN pnpm install --offline
# ########################
# # Build for Node deployment.
# FROM prepare AS build-node
# # ARG RELEASE_NAME
# # ENV RELEASE_NAME=${RELEASE_NAME}
# # ARG SENTRY_AUTH_TOKEN
# # ENV SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}
# ENV NODE_ENV=production
# RUN npm run build
# # RUN pnpm --dir src run build:node
########################
# Build for static deployment.
FROM prepare AS build-static
# ARG SITE_URL=http://localhost:3002
# ENV SITE_URL=${SITE_URL}
ENV NODE_ENV=production
RUN npm run build
# RUN pnpm --dir src run build:static
########################
# Nuxt: lint
FROM prepare AS lint
RUN npm run lint
# RUN pnpm -r run lint
# ########################
# # Nuxt: test (unit)
# FROM prepare AS test-unit
# RUN pnpm -r run test
# ########################
# # Nuxt: test (e2e, base-image)
# FROM mcr.microsoft.com/playwright:v1.49.0 AS test-e2e-base-image
# # The `CI` environment variable must be set for pnpm to run in headless mode
# ENV CI=true
# ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
# WORKDIR /srv/app/
# RUN corepack enable
# ########################
# # Nuxt: test (e2e)
# FROM test-e2e-base-image AS test-e2e_development
# ARG UNAME=e2e
# ARG UID=1000
# ARG GID=1000
# ENV NODE_ENV=development
# COPY ./docker-entrypoint.sh /usr/local/bin/
# RUN groupadd -g $GID -o $UNAME \
# && useradd -m -l -u $UID -g $GID -o -s /bin/bash $UNAME
# USER $UNAME
# VOLUME /srv/.pnpm-store
# VOLUME /srv/app
# ENTRYPOINT ["docker-entrypoint.sh"]
# ########################
# # Nuxt: test (e2e, preparation)
# FROM test-e2e-base-image AS test-e2e-prepare
# COPY --from=prepare /srv/app/ ./
# RUN pnpm -r rebuild
# ########################
# # Nuxt: test (e2e, development)
# FROM test-e2e-prepare AS test-e2e-dev
# ENV NODE_ENV=development
# RUN pnpm --dir tests run test:e2e:server:dev
# ########################
# # Nuxt: test (e2e, node)
# FROM test-e2e-prepare AS test-e2e-node
# COPY --from=build-node /srv/app/src/.output ./src/.output
# RUN pnpm --dir tests run test:e2e:server:node
# ########################
# # Nuxt: test (e2e, static)
# FROM test-e2e-prepare AS test-e2e-static
# COPY --from=build-static /srv/app/src/.output/public ./src/.output/public
# RUN pnpm --dir tests run test:e2e:server:static
#######################
# Collect build, lint and test results.
FROM base-image AS collect
# COPY --from=build-node /srv/app/src/.output ./.output
# COPY --from=build-node /srv/app/src/package.json ./package.json
COPY --from=build-static /srv/app/dist ./dist
COPY --from=lint /srv/app/package.json /tmp/package.json
# COPY --from=test-unit /srv/app/package.json /tmp/package.json
# COPY --from=test-e2e-dev /srv/app/package.json /tmp/package.json
# COPY --from=test-e2e-node /srv/app/package.json /tmp/package.json
# COPY --from=test-e2e-static /srv/app/package.json /tmp/package.json
#######################
# Provide a web server.
FROM nginx:1.27.3-alpine AS production
# The `CI` environment variable must be set for pnpm to run in headless mode
ENV CI=true
ENV NODE_ENV=production
WORKDIR /usr/share/nginx/html
# COPY ./docker/nginx.conf /etc/nginx/nginx.conf
COPY --from=collect /srv/app/dist/ ./
# HEALTHCHECK --interval=10s CMD wget -O /dev/null http://localhost:3000/api/healthcheck || exit 1
EXPOSE 80
LABEL org.opencontainers.image.source="https://github.com/flipdot/app-dashboard"
LABEL org.opencontainers.image.description="https://apps.flipdot.org"
# #######################
# # Provide a web server.
# # Requires node (cannot be static) as the server acts as backend too.
# FROM collect AS production
# ENV NODE_ENV=production
# # Update dependencies.
# RUN apk update \
# && apk upgrade --no-cache
# ENTRYPOINT ["pnpm"]
# CMD ["run", "start:node"]
# HEALTHCHECK --interval=10s CMD wget -O /dev/null http://localhost:3000/api/healthcheck || exit 1
# EXPOSE 3000
# LABEL org.opencontainers.image.source="https://github.com/maevsi/maevsi"
# LABEL org.opencontainers.image.description="Find events, guests and friends 💙❤️💚"