Skip to content

Commit

Permalink
Fully working!
Browse files Browse the repository at this point in the history
...but docker can't write to /etc/hosts file... AARGH!
  • Loading branch information
itaylor committed Mar 10, 2022
1 parent 6c93673 commit cd4af7b
Show file tree
Hide file tree
Showing 4 changed files with 282 additions and 34 deletions.
88 changes: 88 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name = "docker-vhoster"
version = "0.1.0"
edition = "2021"

# [package.release]
# opt-level = 's' # Optimize for size.
# lto = true # Link Time Optimization (LTO)

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand All @@ -12,3 +16,5 @@ serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
chrono = "0.4"
futures-util = "0.3"
futures-retry = "0.6.0"
ctrlc = { version = "3.0", features = ["termination"] }
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
FROM rust:1.59 as BUILD

ARG RUSTFLAGS='-C link-arg=-s'
ARG TARGET='x86_64-unknown-linux-musl'

RUN USER=root cargo new --bin docker-vhoster
WORKDIR /docker-vhoster

# copy over your manifests
COPY ./Cargo.toml ./Cargo.toml

# this build step will cache your dependencies
RUN cargo build --release && rm src/*.rs
ENV RUSTFLAGS=${RUSTFLAGS}
# cache deps
RUN rustup target add ${TARGET} && cargo build --release --target ${TARGET} && rm src/*.rs
COPY ./src /docker-vhoster/src
RUN cargo build --release --bin
# build as a statically linked library
RUN cargo build --release --target ${TARGET} --bin docker-vhoster
#RUN ls -alh /docker-vhoster/target/${TARGET} && exit 1

# our final base
FROM debian:bullseye-slim
# copy the build artifact from the build stage
COPY --from=BUILD docker-vhoster .
# set the startup command to run your binary
CMD ["./docker-vhoster"]
FROM scratch
ARG TARGET='x86_64-unknown-linux-musl'
COPY --from=BUILD /docker-vhoster/target/${TARGET}/release/docker-vhoster /
CMD ["/docker-vhoster"]
Loading

0 comments on commit cd4af7b

Please sign in to comment.