67 lines
1.4 KiB
Docker
67 lines
1.4 KiB
Docker
FROM rust:1.33-slim AS rustbuild
|
|
|
|
WORKDIR /build
|
|
|
|
RUN rustup target add x86_64-unknown-linux-musl
|
|
|
|
ENV USER root
|
|
|
|
ENV CARGO_INSTALL_ROOT /build/bin
|
|
|
|
RUN mkdir -p /build/bin
|
|
|
|
RUN bash -c "cd /tmp/; cargo new --bin index; cd index; echo 'test_crate_hello_world = \"0.1.2\"' >> Cargo.toml; cargo build; cd /tmp; rm -rf index"
|
|
|
|
FROM rustbuild AS eventbuild
|
|
|
|
WORKDIR /build
|
|
|
|
RUN cargo new --lib wg-event-gen
|
|
|
|
COPY wg-event-gen/Cargo.* /build/wg-event-gen/
|
|
|
|
WORKDIR /build/wg-event-gen
|
|
|
|
RUN cargo build --target x86_64-unknown-linux-musl
|
|
|
|
COPY wg-event-gen/src/ /build/wg-event-gen/src/
|
|
|
|
RUN cargo install --debug --path . --target x86_64-unknown-linux-musl
|
|
|
|
|
|
FROM rustbuild AS boringbuild
|
|
|
|
RUN cargo new --bin boringtun && touch boringtun/src/lib.rs
|
|
|
|
COPY boringtun/Cargo.* /build/boringtun/
|
|
|
|
WORKDIR /build/boringtun
|
|
|
|
RUN cargo build --release
|
|
|
|
COPY boringtun/ build/
|
|
|
|
RUN cargo install --path .
|
|
|
|
|
|
FROM frolvlad/alpine-glibc
|
|
|
|
RUN echo http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && apk --no-cache add wireguard-tools bash nload
|
|
|
|
ENV WG_I_PREFER_BUGGY_USERSPACE_TO_POLISHED_KMOD=1
|
|
|
|
COPY --from=eventbuild /build/wg-event-gen /usr/bin/
|
|
|
|
COPY --from=boringbuild /build/boringtun /usr/bin/
|
|
|
|
COPY init.sh /init.sh
|
|
|
|
RUN chmod +x /init.sh && echo 'alias nload="nload ${WG_INTERFACE:-wg0}"' >> /root/.bashrc
|
|
|
|
VOLUME /etc/wireguard/
|
|
|
|
EXPOSE 51820/udp
|
|
|
|
ENTRYPOINT /init.sh
|
|
|