mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-07-23 10:24:15 +00:00
Simple Dockerfile & .dockerignore
This commit is contained in:
parent
1976d02ec9
commit
f3ee84d984
2 changed files with 54 additions and 0 deletions
26
.dockerignore
Normal file
26
.dockerignore
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Binaries and build artifacts
|
||||
*.exe
|
||||
*.out
|
||||
*.test
|
||||
*.tmp
|
||||
|
||||
# Go build/cache directories
|
||||
/bin
|
||||
/pkg
|
||||
/vendor
|
||||
*.log
|
||||
*.cache
|
||||
coverage.*
|
||||
|
||||
# VCS and config noise
|
||||
.git
|
||||
.gitignore
|
||||
.dockerignore
|
||||
*.swp
|
||||
*.swo
|
||||
*.DS_Store
|
||||
.idea/
|
||||
.vscode/
|
||||
|
||||
# Docker artifacts
|
||||
Dockerfile*
|
28
Dockerfile
Normal file
28
Dockerfile
Normal file
|
@ -0,0 +1,28 @@
|
|||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
LABEL org.opencontainers.image.source="https://github.com/XTLS/Xray-core" \
|
||||
org.opencontainers.image.licenses="MPL-2.0" \
|
||||
org.opencontainers.image.title="xray-core"
|
||||
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . ./
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false \
|
||||
-ldflags="-s -w -buildid=" -v ./main
|
||||
|
||||
FROM alpine:3.22.0
|
||||
|
||||
COPY --from=builder /src/xray /usr/local/bin/xray
|
||||
RUN adduser -D -u 10001 xray &&\
|
||||
chmod +x /usr/local/bin/xray &&\
|
||||
mkdir -p /etc/xray /var/log/xray &&\
|
||||
echo {} > /etc/xray/config.json
|
||||
|
||||
WORKDIR /etc/xray
|
||||
USER xray
|
||||
|
||||
ENTRYPOINT ["xray", "-c", "/etc/xray/config.json"]
|
Loading…
Add table
Add a link
Reference in a new issue