Skip to content

Commit 05b32e2

Browse files
committed
fix dockerfile
1 parent 87dcbec commit 05b32e2

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

Dockerfile

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,52 @@ 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+
ARG SECRET_KEY_BASE=dummy_secret
19+
ENV MIX_ENV=$MIX_ENV
20+
ENV SECRET_KEY_BASE=$SECRET_KEY_BASE
1921

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

0 commit comments

Comments
 (0)