File tree Expand file tree Collapse file tree 2 files changed +44
-9
lines changed Expand file tree Collapse file tree 2 files changed +44
-9
lines changed Original file line number Diff line number Diff line change @@ -2,20 +2,54 @@ FROM elixir:1.18.3-otp-27-slim AS base
2
2
3
3
WORKDIR /code_comparison
4
4
5
- # Install system dependencies first!
6
5
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 && \
8
7
apt-get clean && \
9
8
rm -rf /var/lib/apt/lists/*
10
9
11
- # Now it's safe to run mix commands
12
10
RUN mix do local.hex --force, local.rebar --force
13
11
14
- # Copy the entire application
15
- COPY . .
12
+ # -----------------
13
+ # BUILD
14
+ # -----------------
15
+ FROM base AS build
16
16
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
19
21
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" ]
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ secret_key_base =
13
13
14
14
config :code_comparison , CodeComparisonWeb.Endpoint ,
15
15
http: [
16
+ ip: { 0 , 0 , 0 , 0 } ,
16
17
port: String . to_integer ( System . get_env ( "PORT" ) || "4000" ) ,
17
18
transport_options: [ socket_opts: [ :inet6 ] ]
18
19
] ,
You can’t perform that action at this time.
0 commit comments