-
-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathDockerfile.dioxus
More file actions
45 lines (34 loc) · 1.54 KB
/
Dockerfile.dioxus
File metadata and controls
45 lines (34 loc) · 1.54 KB
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
FROM nixos/nix:2.33.2 AS builder
ARG GIT_SHA=unknown
ARG GIT_BRANCH=unknown
ARG BUILD_TIMESTAMP=unknown
ENV NIX_CONFIG="experimental-features = nix-command flakes"
ENV GIT_SHA=${GIT_SHA}
ENV GIT_BRANCH=${GIT_BRANCH}
ENV BUILD_TIMESTAMP=${BUILD_TIMESTAMP}
WORKDIR /app
COPY flake.nix flake.lock ./
RUN git init && git add flake.nix flake.lock
# Downloads all tools from the Nix binary cache (~seconds).
# This layer is cached by Docker as long as flake.nix/flake.lock are unchanged.
RUN nix develop .#frontend --command true
COPY . .
RUN git add -A
RUN nix develop .#frontend --command bash -c "\
cd dioxus-ui && \
tailwindcss -i ./static/leptos-style.css -o ./static/tailwind.css --minify && \
trunk build --release"
# Generate a static version.json so nginx can serve it at /version.json.
# Note: sed is not available in the nix base image, so use shell parameter expansion.
RUN v=$(grep '^version' dioxus-ui/Cargo.toml | head -1) && v="${v#*\"}" && v="${v%\"*}" && \
printf '{"service":"dioxus-ui","version":"%s","git_sha":"%s","git_branch":"%s","build_timestamp":"%s"}\n' \
"$v" "$(echo "${GIT_SHA}" | cut -c1-8)" "${GIT_BRANCH}" "${BUILD_TIMESTAMP}" \
> dioxus-ui/dist/version.json
# ---------------------------------------------------------------------------
FROM nginx:1.21.5-alpine
ARG GIT_SHA=unknown
ARG GIT_BRANCH=unknown
LABEL org.opencontainers.image.revision=${GIT_SHA}
LABEL org.opencontainers.image.ref.name=${GIT_BRANCH}
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /app/dioxus-ui/dist /usr/share/nginx/html