-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (23 loc) · 911 Bytes
/
Dockerfile
File metadata and controls
34 lines (23 loc) · 911 Bytes
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
# Stage 1: Build the application
FROM ocaml/opam:alpine-ocaml-5.3 as build
# Install system dependencies
RUN sudo apk add --update libev-dev openssl-dev postgresql-dev
# Pull the latest OPAM repository updates
RUN cd ~/opam-repository && git pull origin master && opam update
WORKDIR /home/opam
# Copy the project's opam file and install dependencies
COPY --chown=opam:opam app.opam app.opam
RUN opam install . --deps-only
# Copy the rest of the application
COPY --chown=opam:opam . .
# Build the project
RUN opam exec -- dune build @install --profile=release
# Stage 2: Create the runtime image
FROM alpine:3.18 as run
# Install runtime dependencies
RUN apk add --update libev postgresql-libs
# Copy the compiled binary from the build stage
COPY --from=build /home/opam/_build/default/bin/main.exe /bin/server
# Make sure the server is executable
RUN chmod +x /bin/server
ENTRYPOINT ["/bin/server"]