mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-02-28 05:02:59 +00:00
Dockerfile optimization
This commit is contained in:
parent
53d3166108
commit
70e37e09c7
1 changed files with 13 additions and 12 deletions
25
Dockerfile
25
Dockerfile
|
|
@ -7,7 +7,9 @@ ARG TARGETARCH
|
||||||
ARG XRAY_VERSION
|
ARG XRAY_VERSION
|
||||||
ENV CGO_ENABLED=1
|
ENV CGO_ENABLED=1
|
||||||
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
||||||
ENV XRAY_BUILD_DIR="/app/xray-build"
|
ENV XRAY_GEO_FILES_DIR="/app/xray-build"
|
||||||
|
ENV XRAY_BUILD_DIR="/app/build/x-ui"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk add --no-cache --update \
|
RUN apk add --no-cache --update \
|
||||||
|
|
@ -18,15 +20,14 @@ RUN apk add --no-cache --update \
|
||||||
bash
|
bash
|
||||||
|
|
||||||
# Install xray-core and geodat files
|
# Install xray-core and geodat files
|
||||||
RUN mkdir -p "$XRAY_BUILD_DIR"
|
RUN mkdir -p "$XRAY_GEO_FILES_DIR"
|
||||||
COPY lib/geo.sh "$XRAY_BUILD_DIR"/
|
COPY lib/geo.sh "$XRAY_GEO_FILES_DIR"/
|
||||||
COPY lib/xray-tools.sh "$XRAY_BUILD_DIR"/
|
COPY lib/xray-tools.sh "$XRAY_GEO_FILES_DIR"/
|
||||||
|
|
||||||
RUN chmod +x "$XRAY_BUILD_DIR"/xray-tools.sh \
|
|
||||||
&& chmod +x "$XRAY_BUILD_DIR"/geo.sh
|
|
||||||
RUN "$XRAY_BUILD_DIR"/xray-tools.sh install_xray_core "$TARGETARCH" "$XRAY_BUILD_DIR"/bin "$XRAY_VERSION" \
|
|
||||||
&& "$XRAY_BUILD_DIR"/geo.sh update_all_geofiles "$XRAY_BUILD_DIR"/bin
|
|
||||||
|
|
||||||
|
RUN chmod +x "$XRAY_GEO_FILES_DIR"/xray-tools.sh \
|
||||||
|
&& chmod +x "$XRAY_GEO_FILES_DIR"/geo.sh
|
||||||
|
RUN "$XRAY_GEO_FILES_DIR"/xray-tools.sh install_xray_core "$TARGETARCH" "$XRAY_GEO_FILES_DIR"/bin "$XRAY_VERSION" \
|
||||||
|
&& "$XRAY_GEO_FILES_DIR"/geo.sh update_all_geofiles "$XRAY_GEO_FILES_DIR"/bin
|
||||||
|
|
||||||
# docker CACHE
|
# docker CACHE
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
|
|
@ -42,21 +43,21 @@ COPY util/ util/
|
||||||
COPY xray/ xray/
|
COPY xray/ xray/
|
||||||
COPY main.go ./
|
COPY main.go ./
|
||||||
|
|
||||||
RUN go build -ldflags "-w -s" -o build/x-ui main.go
|
RUN go build -ldflags "-w -s" -o "$XRAY_BUILD_DIR" main.go
|
||||||
|
|
||||||
# ========================================================
|
# ========================================================
|
||||||
# Stage: Final Image of 3x-ui
|
# Stage: Final Image of 3x-ui
|
||||||
# ========================================================
|
# ========================================================
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
tzdata \
|
tzdata \
|
||||||
fail2ban \
|
fail2ban \
|
||||||
bash
|
bash
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
COPY DockerEntrypoint.sh ./
|
COPY DockerEntrypoint.sh ./
|
||||||
COPY --from=builder /app/build/x-ui ./
|
COPY --from=builder /app/build/x-ui ./
|
||||||
COPY --from=builder /app/xray-build/bin/ /tmp/xray/
|
COPY --from=builder /app/xray-build/bin/ /tmp/xray/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue