Add dockerfile

Former-commit-id: 60c54d79124631c50746da75a423ee9388f8d985 [formerly a2710f80a818c2210caba8c49c9c1269989b1c2b] [formerly 4ca6cef8b2c71a460f97d233a38ba8a2ddf5f15f [formerly dc7215f367]]
Former-commit-id: 526b7c11e56b823e81cca101c0445df4f8bb631e [formerly 4acd501be9a53cde0b71f92ea050c91cf4cd9fb2]
Former-commit-id: aab8a87343f586f63e50bcb6da5e45ab641da6c5
Former-commit-id: 04c30b381d1cdd3acd33c7ca4c8c127b1382a67c
Former-commit-id: 545d3c452a2ff578d6b735438979114e340d54c2
Former-commit-id: 3f914bde058d210a22958ef0a9e9208a19e97d9d [formerly 41028124b438740222c1dd4022cb283fe67d4251]
Former-commit-id: 01b376228fd7620db2ca5c9472e19c829f99020b
pull/192/head
Σrebe - Romain GERARD 2023-10-21 16:49:24 +02:00
parent 547b6b24f8
commit b37b00ca41
4 changed files with 65 additions and 2 deletions

View File

@ -1,2 +1,2 @@
.stack-work
.travis.yml
target
.github

61
Dockerfile Normal file
View File

@ -0,0 +1,61 @@
ARG BUILDER_IMAGE=builder_cache
ARG ALPINE_IMAGE_TAG=3.18
############################################################
# Cache image with all the deps
FROM rust:1.73-alpine${ALPINE_IMAGE_TAG} AS builder_cache
RUN apk add musl-dev
RUN rustup component add rustfmt clippy
WORKDIR /build
COPY . ./
RUN cargo fmt --all -- --check --color=always || (echo "Use cargo fmt to format your code"; exit 1)
RUN cargo clippy --all --all-features -- -D warnings || (echo "Solve your clippy warnings to succeed"; exit 1)
#RUN cargo test --all --all-features
#RUN just test "tcp://localhost:2375" || (echo "Test are failing"; exit 1)
#ENV RUSTFLAGS="-C link-arg=-Wl,--compress-debug-sections=zlib -C force-frame-pointers=yes"
RUN cargo build --tests --all-features
#RUN cargo build --release --all-features
############################################################
# Builder for production image
FROM ${BUILDER_IMAGE} AS builder_release
WORKDIR /build
COPY . ./
ARG BIN_TARGET=--bins
ARG PROFILE=release
#ENV RUSTFLAGS="-C link-arg=-Wl,--compress-debug-sections=zlib -C force-frame-pointers=yes"
RUN cargo build --profile=${PROFILE} ${BIN_TARGET}
############################################################
# Final image
FROM alpine:${ALPINE_IMAGE_TAG} as final-image
RUN apk add dumb-init && \
adduser -Ds /bin/sh app
WORKDIR /home/app
ARG PROFILE=release
COPY --from=builder_release /build/target/${PROFILE}/wstunnel wstunnel
ENV RUST_LOG="INFO"
ENV SERVER_PROTOCOL="wss"
ENV SERVER_LISTEN="[::]"
ENV SERVER_PORT="8080"
EXPOSE 8080
USER app
ENTRYPOINT ["/usr/bin/dumb-init", "-v", "--"]
CMD ["/bin/sh", "-c", "exec /home/app/wstunnel server ${SERVER_PROTOCOL}://${SERVER_LISTEN}:${SERVER_PORT}"]

View File

@ -225,6 +225,7 @@ fn parse_local_bind(arg: &str) -> Result<(SocketAddr, &str), io::Error> {
Ok((SocketAddr::new(bind, bind_port), remaining))
}
#[allow(clippy::type_complexity)]
fn parse_tunnel_dest(
remaining: &str,
) -> Result<(Host<String>, u16, BTreeMap<String, String>), io::Error> {

View File

@ -11,6 +11,7 @@ use tokio::net::TcpStream;
use tracing::{info, warn};
use url::Host;
#[allow(clippy::type_complexity)]
pub struct Socks5Listener {
stream: Pin<Box<dyn Stream<Item = anyhow::Result<(TcpStream, (Host, u16))>> + Send>>,
}