-
Notifications
You must be signed in to change notification settings - Fork 105
/
Dockerfile.multiarch
71 lines (47 loc) · 1.4 KB
/
Dockerfile.multiarch
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
# 使用构建基础镜像复制源代码执行编译
FROM gramoss/mini-build-base:20240521 as compile
ARG TARGETARCH
ENV MIX_ENV=prod
WORKDIR /src
COPY . /src/
RUN set -xe \
&& if [ "$TARGETARCH" = "arm64" ]; then \
# Avoid QEMU/arm64 build failed. \
export ERL_FLAGS="+JMsingle true"; \
fi \
&& xbps-install -Sy git \
&& mix deps.get \
&& mix compile
# 使用 Node 镜像构建前端
FROM node:20 as assets-build
WORKDIR /src
COPY --from=compile /src/ /src/
RUN set -xe \
&& npm install --location=global [email protected] \
&& pnpm --prefix assets install \
&& pnpm --prefix assets run deploy \
&& pnpm --prefix webapps install \
&& pnpm --prefix webapps build
# 使用构建基础镜像 release 应用
FROM gramoss/mini-build-base:20240521 as release
ARG TARGETARCH
ENV MIX_ENV=prod
WORKDIR /src
COPY --from=assets-build /src/ /src/
RUN set -xe \
&& if [ "$TARGETARCH" = "arm64" ]; then \
# Avoid QEMU/arm64 build failed. \
export ERL_FLAGS="+JMsingle true"; \
fi \
&& xbps-install -Sy git \
&& mix local.hex --force \
&& mix local.rebar --force \
&& mix phx.digest \
&& mix release
# 使用运行基础镜像打包
FROM gramoss/mini-run-base:20240521
ARG APP_HOME=/home/policr_mini
COPY --from=release /src/_build/prod/rel/policr_mini $APP_HOME
WORKDIR $APP_HOME
ENV PATH="$APP_HOME/bin:$PATH"
ENTRYPOINT [ "policr_mini", "start" ]