forked from mirego/accent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
100 lines (77 loc) · 2.29 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
99
#
# Build webapp and jipt deps
#
FROM node:16.19-bullseye-slim AS webapp-builder
RUN apt-get update -y && \
apt-get install -y build-essential git python3 python3-pip && \
apt-get clean && \
rm -f /var/lib/apt/lists/*_*
WORKDIR /opt/build
COPY webapp .
RUN npm ci --no-audit --no-color && \
npm run build-production
FROM node:16.19-bullseye-slim AS jipt-builder
RUN apt-get update -y && \
apt-get install -y build-essential git python3 python3-pip && \
apt-get clean && \
rm -f /var/lib/apt/lists/*_*
WORKDIR /opt/build
COPY jipt .
RUN npm ci --no-audit --no-color && \
npm run build-production
#
# Build the OTP binary
#
FROM hexpm/elixir:1.14.3-erlang-25.1.2-debian-bullseye-20221004-slim AS builder
ENV MIX_ENV=prod
WORKDIR /build
# Install Debian dependencies
RUN apt-get update -y && \
apt-get install -y build-essential git libyaml-dev && \
apt-get clean && \
rm -f /var/lib/apt/lists/*_*
RUN mix local.rebar --force && \
mix local.hex --force
COPY mix.* ./
COPY lib lib
COPY priv priv
COPY config config
COPY mix.exs .
COPY mix.lock .
RUN mix deps.get --only prod
RUN mix deps.compile --only prod
RUN mix compile --only prod
# Move static assets from other stages into the OTP release.
# Those file will be served by the Elixir app.
COPY --from=webapp-builder /opt/build/webapp-dist ./webapp-dist
COPY --from=jipt-builder /opt/build/jipt-dist ./jipt-dist
RUN mv webapp-dist priv/static/webapp && \
mv jipt-dist priv/static/jipt
RUN mkdir -p /opt/build && \
mix release && \
cp -R _build/prod/rel/accent/* /opt/build
#
# Build a lean runtime container
#
FROM alpine:3.17.0
FROM debian:bullseye-20230109
RUN apt-get update -y && \
apt-get install -y bash libyaml-dev openssl libncurses5 locales fontconfig && \
apt-get clean && \
rm -f /var/lib/apt/lists/*_*
# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV MIX_ENV="prod"
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
WORKDIR /opt/accent
# Create a non-root user
RUN chown nobody /opt/accent
COPY --from=builder --chown=nobody:root /opt/build .
# Copy the entrypoint script
COPY priv/scripts/docker-entrypoint.sh /usr/local/bin
RUN chmod a+x /usr/local/bin/docker-entrypoint.sh
USER nobody
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]