diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0bf8769 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM golang:1.20 as builder + +ARG TARGETOS +ARG TARGETARCH +ENV GOPROXY=https://goproxy.io,direct + +WORKDIR / + +COPY go.mod go.mod +COPY go.sum go.sum +COPY pkg pkg +COPY main.go main.go + +RUN CGO_ENABLED=1 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o virtuallan main.go + +FROM alpine:3.19 + +WORKDIR / + +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories +RUN apk add --no-cache gcompat + +COPY config config +COPY static static +COPY --from=builder virtuallan virtuallan +CMD /virtuallan server -d /config \ No newline at end of file diff --git a/Makefile b/Makefile index 32484b0..ca1d561 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ .DEFAULT_GOAL := build +IMG ?= virtuallan:latest +CONTAINER_TOOL ?= docker .PHONY: gen gen: @@ -11,3 +13,7 @@ build: gen .PHONY: clean clean: rm -rf virtuallan + +.PHONY: build-docker +build-docker: gen + $(CONTAINER_TOOL) build -t ${IMG} . \ No newline at end of file diff --git a/README.md b/README.md index 9bf2cdb..eeeb45e 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,14 @@ go build -o virtuallan main.go go generate will generate an random aes key +## Use with docker + +**Build** +>IMG=\:\ make build-docker + +**Run docker image as server** +>docker run --privileged=true -d --restart always -p 6123:6123/udp -p 8000:8000 quay.io/shawnlu0127/virtuallan:20240507 + ## Getting started **Server** @@ -88,6 +96,7 @@ OPTIONS: ### Try it out If enable web, it will start a http server on port 8000. Check the endpoints in index page. + ![monitor](./docs/statics/endpoints.png) Links of virtuallan server