docker container

This commit is contained in:
serxoz 2024-04-16 17:39:33 +02:00
parent 026b0285a9
commit 8977678fb2
3 changed files with 43 additions and 2 deletions

29
Dockerfile Normal file
View File

@ -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"]

View File

@ -1,3 +1,6 @@
NAME = sip-tarpit
VERSION = 0.0.1
all: all:
cargo build cargo build
@ -12,3 +15,12 @@ release:
clean: clean:
sudo rm -rf target 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)

View File

@ -1,7 +1,7 @@
[listen] [listen]
# address and port to listen # address and port to listen
bind_addr = "127.0.0.1" bind_addr = "0.0.0.0"
bind_port = 5063 bind_port = 5060
[log] [log]
# log file location # log file location