Skip to content

Commit 7f33953

Browse files
committed
fix dockerfile
1 parent 87dcbec commit 7f33953

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

Dockerfile

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,49 @@ FROM elixir:1.18.3-otp-27-slim AS base
22

33
WORKDIR /code_comparison
44

5-
# Install system dependencies first!
65
RUN apt-get update && \
7-
apt-get install -y npm inotify-tools ca-certificates && \
6+
apt-get install -y npm inotify-tools ca-certificates curl bash git && \
87
apt-get clean && \
98
rm -rf /var/lib/apt/lists/*
109

11-
# Now it's safe to run mix commands
1210
RUN mix do local.hex --force, local.rebar --force
1311

14-
# Copy the entire application
15-
COPY . .
12+
# -----------------
13+
# BUILD
14+
# -----------------
15+
FROM base AS build
1616

17-
# Install Elixir dependencies
18-
RUN mix deps.get
17+
ARG MIX_ENV=prod
18+
ENV MIX_ENV=$MIX_ENV
19+
COPY . ./
1920

20-
# Install npm dependencies
21-
RUN cd assets && npm install
21+
# install application
22+
RUN mix do deps.get, compile
23+
24+
# -----------------
25+
# RELEASE
26+
# -----------------
27+
FROM build AS release
28+
29+
# digests and compresses static files
30+
RUN mix assets.deploy
31+
32+
# generate release executable
33+
RUN mix release
34+
35+
# -----------------
36+
# PRODUCTION
37+
# -----------------
38+
FROM alpine:3.18 AS production
39+
40+
WORKDIR /code_comparison
41+
42+
ARG MIX_ENV=prod
43+
44+
# install dependencies
45+
RUN apk add --no-cache ncurses-libs curl
46+
47+
COPY --from=release /code_comparison/_build/$MIX_ENV/rel/code_comparison ./
48+
49+
# start application
50+
CMD ["bin/code_comparison", "start"]

0 commit comments

Comments
 (0)