-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (34 loc) · 1.24 KB
/
Copy pathDockerfile
File metadata and controls
49 lines (34 loc) · 1.24 KB
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
41
42
43
44
45
46
47
48
49
FROM elixir:1.18.3-otp-27-alpine AS build
# Set the environment to production
ENV MIX_ENV=prod
# Prepare build directory
# According to the FHS, the “opt/” folder is reserved for the installation of add-on application software packages
# In this context, “add-on” means software that is not part of the system
WORKDIR /opt/task_system
# Install build dependencies
RUN apk add --no-cache build-base
# Install Hex and Rebar
RUN mix do local.hex --force, local.rebar --force
# Copy mix files
COPY mix.exs mix.lock ./
# Fetch and compile application dependencies
RUN mix do deps.get, deps.compile
# Copy only the folder containing the exercise logic
# This avoids copying files that are useless for compilation purposes
COPY lib/ lib/
# Compile the application
RUN mix compile
# Release the application
RUN mix release
# Alpine images are the smallest in size
FROM alpine:3.21
# Install application dependencies
RUN apk add --no-cache build-base ncurses-libs
# Prepare application directory
WORKDIR /opt/task_system
# Copy all release files
COPY --from=build /opt/task_system/_build/prod/rel/task_system/ ./
# The entrypoint for starting a command is the application binary
ENTRYPOINT [ "bin/task_system" ]
# Start the application
CMD [ "start" ]