-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
98 lines (75 loc) · 1.96 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
##
# Assets
FROM node:14 AS assets
RUN set -xe; \
apt-get update; \
apt-get install -y --no-install-recommends \
inotify-tools \
git \
python3 make g++ \
; \
rm -rf /var/lib/apt/lists/*
WORKDIR /app/assets
RUN mkdir -p /app/priv/static
COPY ./assets ./
ARG ENV=prod
ENV NODE_ENV $ENV
RUN yarn install
RUN if [ "$ENV" = "prod" ]; then yarn run deploy; fi
##
# App
FROM elixir:1.13-slim AS app
RUN apt-get update && \
apt-get install -y --no-install-recommends \
inotify-tools \
git \
make \
gcc \
libssl1.1 \
ca-certificates \
build-essential \
&& \
rm -rf /var/lib/apt/lists/*
# Set environment variables for building the application
ARG ENV=prod
ENV MIX_ENV $ENV
ENV LANG=C.UTF-8
# Install hex and rebar
RUN mix local.hex --force && \
mix local.rebar --force
# Create the application build directory
RUN mkdir -p /app
WORKDIR /app
# Install and compile dependencies
COPY mix.* ./
RUN mix deps.get
RUN mix deps.compile
# Copy generated assets from asset container
RUN mkdir -p priv/static
COPY --from=assets /app/priv/static/ ./priv/static/
# workaround until docker or someone else gets his shit together
RUN true
# Fetch the application dependencies and build the application
COPY . ./
RUN mix compile --warning-as-errors
RUN if [ "$ENV" = "prod" ]; then mix do phx.digest, release absolventenfeier; fi
##
# Run
FROM debian:buster-slim
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -qq update && \
apt-get install -y --no-install-recommends \
locales openssl && \
rm -rf /var/lib/apt/lists/*
# Set LOCALE to UTF8
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen en_US.UTF-8 && \
dpkg-reconfigure locales && \
/usr/sbin/update-locale LANG=en_US.UTF-8
ENV LC_ALL en_US.UTF-8
# Copy over the build artifact from the previous step and create a non root user
WORKDIR /app
COPY --from=app /app/_build/prod/rel/absolventenfeier ./
COPY Procfile ./
ENTRYPOINT ["./bin/absolventenfeier"]
CMD ["start"]