-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathContainerfile.codebattle
More file actions
86 lines (62 loc) · 2.24 KB
/
Containerfile.codebattle
File metadata and controls
86 lines (62 loc) · 2.24 KB
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
FROM node:24.11-alpine AS assets-image
ENV MIX_ENV=prod
WORKDIR /tmp/codebattle
# Install pnpm globally
RUN npm install --global pnpm
COPY apps/codebattle/package.json apps/codebattle/pnpm-lock.yaml ./
RUN pnpm install
COPY apps/codebattle/postcss.config.js apps/codebattle/.babelrc apps/codebattle/vite.config.js ./
COPY apps/codebattle/assets ./assets
COPY apps/codebattle/priv/gettext ./priv/gettext
RUN pnpm run build
FROM elixir:1.19.1-otp-28-alpine AS compile-image
ENV MIX_ENV=prod
WORKDIR /opt/app
RUN apk update && apk add --no-cache build-base git ca-certificates make curl \
&& mix local.hex --force \
&& mix local.rebar --force
COPY mix.exs .
COPY mix.lock .
COPY config ./config
COPY apps/runner/mix.exs apps/runner/mix.exs
COPY apps/phoenix_gon/mix.exs apps/phoenix_gon/mix.exs
COPY apps/codebattle/mix.exs apps/codebattle/mix.exs
RUN mix do deps.get --only prod, deps.compile
COPY ./apps/codebattle/ ./apps/codebattle/
COPY ./apps/runner/ ./apps/runner/
COPY ./apps/phoenix_gon/ ./apps/phoenix_gon/
COPY --from=assets-image /tmp/codebattle/priv/static ./apps/codebattle/priv/static
RUN mix phx.digest \
&& mix release codebattle \
&& mv _build/prod/rel/codebattle /opt/release
FROM alpine:3.23 AS nginx-assets
RUN apk add --no-cache nginx nginx-mod-http-brotli brotli
COPY nginx.conf /etc/nginx/http.d/default.conf
COPY nginx-assets-entrypoint.sh /opt/nginx-assets-entrypoint.sh
COPY --from=compile-image /opt/release/lib/codebattle-0.1.0/priv/static/assets/ /var/www/assets
RUN find /var/www/assets -type f \( \
-name "*.js" -o \
-name "*.mjs" -o \
-name "*.css" -o \
-name "*.html" -o \
-name "*.json" -o \
-name "*.map" -o \
-name "*.svg" -o \
-name "*.txt" -o \
-name "*.xml" -o \
-name "*.csv" -o \
-name "*.ico" \
\) -exec sh -c 'gzip -f -k -9 "$1" && brotli -f -q 11 "$1"' _ {} \;
RUN chmod +x /opt/nginx-assets-entrypoint.sh
CMD ["/opt/nginx-assets-entrypoint.sh"]
FROM elixir:1.19.1-otp-28-alpine AS runtime-image
RUN apk add --no-cache ca-certificates chromium git make curl vim
ARG GIT_HASH
ENV APP_VERSION=$GIT_HASH
ENV PORT=4000
ENV MIX_ENV=prod
EXPOSE ${PORT}
WORKDIR /opt/app
COPY --from=compile-image /opt/release .
COPY Makefile Makefile
CMD ["/opt/app/bin/codebattle", "start"]