forked from thoth-pub/thoth
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (57 loc) · 1.9 KB
/
Dockerfile
File metadata and controls
73 lines (57 loc) · 1.9 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
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
ARG RUST_IMAGE=rust:1.70.0
ARG MUSL_IMAGE=clux/muslrust:1.70.0
FROM ${RUST_IMAGE} as wasm
ENV NPM_VERSION=9.6.7
ENV N_VERSION=9.0.1
ENV NODE_VERSION=18.16.0
ENV ROLLUP_VERSION=3.23.1
ENV WASM_PACK_VERSION=0.12.0
ARG THOTH_GRAPHQL_API=https://api.thoth.pub
ARG THOTH_EXPORT_API=https://export.thoth.pub
ENV THOTH_GRAPHQL_API=${THOTH_GRAPHQL_API}
ENV THOTH_EXPORT_API=${THOTH_EXPORT_API}
WORKDIR /wasm
# Install build dependencies
RUN apt-get update && apt-get -y install pkg-config npm
RUN npm install -g n@${N_VERSION}
RUN n ${NODE_VERSION}
RUN npm install -g npm@${NPM_VERSION}
RUN npm install -g rollup@${ROLLUP_VERSION}
RUN cargo install wasm-pack --version ${WASM_PACK_VERSION}
# Get source
COPY . .
# Compile WASM for release
RUN wasm-pack build thoth-app/ \
--target web \
--release
RUN rollup thoth-app/main.js \
--format iife \
--file thoth-app/pkg/thoth_app.js
# Switch to musl for static compiling
FROM ${MUSL_IMAGE} as build
# "An ARG instruction goes out of scope at the end of the build stage where it was defined.
# To use an arg in multiple stages, each stage must include the ARG instruction."
# https://docs.docker.com/engine/reference/builder/#scope
ARG THOTH_GRAPHQL_API=https://api.thoth.pub
ARG THOTH_EXPORT_API=https://export.thoth.pub
ENV THOTH_GRAPHQL_API=${THOTH_GRAPHQL_API}
ENV THOTH_EXPORT_API=${THOTH_EXPORT_API}
COPY --from=wasm /wasm/ /volume/
# Build Thoth for release
RUN cargo build --release
# Switch to minimal image for run time
FROM scratch
# Get thoth and diesel binaries
COPY --from=build \
/volume/target/x86_64-unknown-linux-musl/release/thoth /
# Get CA certificates
COPY --from=build \
/etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
# Expose thoth's default ports
EXPOSE 8080
EXPOSE 8000
EXPOSE 8181
# Make thoth our default binary
ENTRYPOINT ["/thoth"]
# By default run `thoth init` (runs migrations and starts the server on port 8080)
CMD ["init"]