Skip to content

Commit cb50f4e

Browse files
committed
fix dockerfile
1 parent 87dcbec commit cb50f4e

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

Dockerfile

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,54 @@ 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+
# Build static assets and digest them
33+
RUN npm install --prefix assets && npm run deploy --prefix assets && mix phx.digest
34+
35+
# generate release executable
36+
RUN mix release
37+
38+
# -----------------
39+
# PRODUCTION
40+
# -----------------
41+
FROM elixir:1.18.3-otp-27-slim AS production
42+
43+
WORKDIR /code_comparison
44+
45+
ARG MIX_ENV=prod
46+
47+
# install dependencies
48+
RUN apt-get update && \
49+
apt-get install -y ncurses-bin curl && \
50+
apt-get clean && \
51+
rm -rf /var/lib/apt/lists/*
52+
53+
COPY --from=release /code_comparison/_build/$MIX_ENV/rel/code_comparison ./
54+
55+
CMD ["bin/code_comparison", "start"]

config/prod.secret.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ secret_key_base =
1313

1414
config :code_comparison, CodeComparisonWeb.Endpoint,
1515
http: [
16+
ip: {0, 0, 0, 0},
1617
port: String.to_integer(System.get_env("PORT") || "4000"),
1718
transport_options: [socket_opts: [:inet6]]
1819
],

0 commit comments

Comments
 (0)