From 8977678fb2893e9975ace436ed65e86bade94fcf Mon Sep 17 00:00:00 2001 From: serxoz Date: Tue, 16 Apr 2024 17:39:33 +0200 Subject: [PATCH] docker container --- Dockerfile | 29 +++++++++++++++++++++++++++++ Makefile | 12 ++++++++++++ config.toml | 4 ++-- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9cbca1b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +################################################################################ +# Builder +################################################################################ +FROM clux/muslrust:stable AS builder + +WORKDIR /app +COPY . . + +RUN cargo build --release +RUN strip target/x86_64-unknown-linux-musl/release/sip-tarpit + +################################################################################ +# Final stage +################################################################################ +FROM alpine:latest + +# Create a group and user +RUN addgroup -S appgroup && adduser -S appuser -G appgroup + +WORKDIR /app + +# Copy our build +COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/sip-tarpit /app/sip-tarpit + +# Tell docker that all future commands should run as the appuser user +USER appuser:appgroup + +# Run +CMD ["/app/sip-tarpit"] diff --git a/Makefile b/Makefile index 4c8a4e3..93b12ce 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +NAME = sip-tarpit +VERSION = 0.0.1 + all: cargo build @@ -12,3 +15,12 @@ release: clean: sudo rm -rf target + +docker-build: + docker build --no-cache -t $(NAME):$(VERSION) . + +docker-run: + docker run --rm --name $(NAME) \ + --expose 5060/udp -p 5063:5060/udp \ + --mount type=bind,source="$(PWD)"/config.toml,target=/app/config.toml,readonly \ + $(NAME):$(VERSION) diff --git a/config.toml b/config.toml index 560d66a..7e11de1 100644 --- a/config.toml +++ b/config.toml @@ -1,7 +1,7 @@ [listen] # address and port to listen -bind_addr = "127.0.0.1" -bind_port = 5063 +bind_addr = "0.0.0.0" +bind_port = 5060 [log] # log file location