awacke1 commited on
Commit
4351a7a
·
1 Parent(s): 079fe48

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +71 -0
Dockerfile ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian instead of
2
+ # Alpine to avoid DNS resolution issues in production.
3
+ #
4
+ # https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu
5
+ # https://hub.docker.com/_/ubuntu?tab=tags
6
+ #
7
+ #
8
+ # This file is based on these images:
9
+ #
10
+ # - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
11
+ # - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20210902-slim - for the release image
12
+ # - https://pkgs.org/ - resource for finding needed packages
13
+ # - Ex: hexpm/elixir:1.13.4-erlang-24.0.1-debian-bullseye-20210902-slim
14
+ #
15
+ ARG ELIXIR_VERSION=1.14.2
16
+ ARG OTP_VERSION=25.1
17
+ ARG DEBIAN_VERSION=bullseye-20220801-slim
18
+
19
+ ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
20
+ ARG RUNNER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
21
+
22
+ FROM ${BUILDER_IMAGE} as builder
23
+
24
+ # install build dependencies
25
+ RUN apt-get update -y && apt-get install -y build-essential git curl \
26
+ && apt-get clean && rm -f /var/lib/apt/lists/*_*
27
+
28
+ # prepare build dir
29
+ WORKDIR /app
30
+
31
+ # set build ENV
32
+ ENV MIX_ENV="prod"
33
+ ENV MIX_HOME="/app/.mix"
34
+ ENV EXS_DRY_RUN="true"
35
+ ENV MIX_INSTALL_DIR="/app/.mix"
36
+ ENV BUMBLEBEE_CACHE_DIR="/app/.bumblebee"
37
+
38
+ # install hex + rebar
39
+ RUN mix local.hex --force && \
40
+ mix local.rebar --force
41
+
42
+ # install mix dependencies
43
+ COPY run.exs ./
44
+ RUN elixir ./run.exs
45
+
46
+ # start a new build stage so that the final image will only contain
47
+ # the compiled release and other runtime necessities
48
+ FROM ${RUNNER_IMAGE}
49
+
50
+ # install build dependencies
51
+ RUN apt-get update -y && apt-get install -y build-essential git curl \
52
+ && apt-get clean && rm -f /var/lib/apt/lists/*_*
53
+
54
+ WORKDIR "/app"
55
+
56
+ # set runner ENV
57
+ ENV MIX_ENV="prod"
58
+ ENV MIX_HOME="/app/.mix"
59
+ ENV MIX_INSTALL_DIR="/app/.mix"
60
+ ENV BUMBLEBEE_CACHE_DIR="/app/.bumblebee"
61
+ ENV SHELL=/bin/bash
62
+ ENV PORT=7860
63
+
64
+ EXPOSE 7860
65
+
66
+ # Only copy the final release from the build stage
67
+ COPY --from=builder --chown=nobody:root /app/.mix/ ./.mix
68
+ COPY --from=builder --chown=nobody:root /app/.bumblebee/ ./.bumblebee
69
+ COPY --from=builder --chown=nobody:root /app/run.exs ./
70
+
71
+ CMD ["elixir", "/app/run.exs"]