-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (41 loc) · 1.06 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (41 loc) · 1.06 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
# Build stage
FROM elixir:1.15-alpine AS build
# Install build dependencies
RUN apk add --update git build-base nodejs npm
RUN mkdir /app
WORKDIR /app
# Install Hex + Rebar
RUN mix do local.hex --force, local.rebar --force
# Set build ENV
ENV MIX_ENV=prod
# Install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix deps.get --only $MIX_ENV
RUN mix deps.compile
# Build project FIRST - this generates phoenix-colocated hooks
COPY lib lib
RUN mix compile
# Build assets AFTER - now phoenix-colocated is available
COPY assets assets
COPY priv priv
RUN mix assets.deploy
# Build release
RUN mix release
# App stage
FROM alpine:3.18 AS app
# Install runtime dependencies
RUN apk add --update bash openssl postgresql-client libstdc++ libgcc ncurses-libs
EXPOSE 4000
ENV MIX_ENV=prod
# Prepare app directory
RUN mkdir /app
WORKDIR /app
# Copy release to app container
COPY --from=build /app/_build/prod/rel/blitzkeys .
COPY entrypoint.sh .
RUN chmod +x /app/entrypoint.sh
RUN chown -R nobody: /app
USER nobody
ENV HOME=/app
CMD ["bash", "/app/entrypoint.sh"]