-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.here-now
74 lines (59 loc) · 2.51 KB
/
Dockerfile.here-now
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
# Test with
# docker build --file=./Dockerfile.here-now -t herenow/server . && docker run -it herenow/server /bin/bash
FROM herenow/dev-tools:latest as dev-tools
FROM rust:1.70.0-bullseye as rust-toolchain
WORKDIR /build
# 1. When the `rust-toolchain.toml` is changed,
COPY ./rust-toolchain.toml /
COPY ./rust-toolchain.toml ./rust-toolchain.toml
# 2. then `rustup show` will download the appropriate components (which is now cached based on just one file)
RUN rustup show
RUN rustup default
FROM rust-toolchain as builder
RUN ln -s $(which cargo) /usr/bin/cargo
# # Copy in the manifest information for our dependencies
# # We can then build a minimal version of the workspace and cache that work.
COPY ./vendor ./vendor
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
COPY ./.cargo ./.cargo
COPY ./hn-desktop/Cargo.toml ./hn-desktop/Cargo.toml
COPY ./docker/dummy/main.rs ./hn-desktop/src/main.rs
# COPY ./hn-server/Cargo.toml ./hn-server/Cargo.toml
# COPY ./docker/dummy/main.rs ./hn-server/src/main.rs
# COPY ./hn-public-api/Cargo.toml ./hn-public-api/Cargo.toml
# COPY ./docker/dummy/lib.rs ./hn-public-api/src/lib.rs
# COPY ./hn-keys/Cargo.toml ./hn-keys/Cargo.toml
# COPY ./docker/dummy/lib.rs ./hn-keys/src/lib.rs
COPY ./xtask/Cargo.toml ./xtask/Cargo.toml
COPY ./docker/dummy/main.rs ./xtask/src/main.rs
# # cache dependencies (download and compile them)
# # 👇 and here's some caches!
# RUN --mount=type=cache,target=/root/.rustup \
# --mount=type=cache,target=/root/.cargo/registry \
# --mount=type=cache,target=/root/.cargo/git \
# --mount=type=cache,target=/build/target \
# set -eux; \
# cargo build --release -p hn-server;
# Copy in the actually changed code
COPY ./hn-server ./hn-server
COPY ./hn-hinted-id ./hn-hinted-id
COPY ./hn-public-api ./hn-public-api
COPY ./hn-keys ./hn-keys
# Build a release
RUN --mount=type=cache,target=/root/.rustup \
--mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
--mount=type=cache,target=/build/target \
set -eux; \
cargo build --release -p hn-server; \
# copy out of the cache directory (which gets unmounted after the build)
cp /build/target/release/hn-server /bin/hn-server;
FROM debian:bullseye-slim as hn-server
WORKDIR /app
COPY --from=dev-tools /dev-tools/bin/jaeger-all-in-one jaegar-all-in-one
COPY --from=builder /bin/hn-server /bin/hn-server
# copy for the static files for server
COPY --from=builder /build/hn-server /app/hn-server
ENV HERE_NOW_SERVER_SRC_PATH=/app/hn-server
CMD ["/bin/hn-server"]