-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (28 loc) · 802 Bytes
/
Dockerfile
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
# Step 1: Use the official Elixir image as a base
FROM elixir:latest AS build
# Step 2: Set environment to production
ENV MIX_ENV=prod
# Step 3: Install Hex + Rebar
RUN mix local.hex --force && \
mix local.rebar --force
# Set the working directory inside the container
WORKDIR /app
# Copy all dependencies files
COPY mix.exs mix.lock ./
# Fetch the application dependencies and build the application
RUN mix deps.get
RUN mix deps.compile
# Step 4: Compile the application
COPY . .
RUN mix compile
# Step 5: Build the release
RUN mix escript.build
# Step 6: Prepare release image
FROM erlang:latest AS runtime
WORKDIR /app
# Copy the release build from the previous stage
COPY --from=build /app/js ./js
ENV PATH="/app:${PATH}"
ENV LC_ALL=C.UTF-8
# Step 7: Run the application
CMD ["js"]