1
0

Dockerfile 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # ========================================================
  2. # Stage: Builder
  3. # ========================================================
  4. FROM --platform=$BUILDPLATFORM golang:1.20.4-alpine AS builder
  5. WORKDIR /app
  6. ARG TARGETARCH
  7. ENV CGO_ENABLED=1
  8. RUN apk --no-cache --update add \
  9. build-base \
  10. gcc \
  11. wget \
  12. unzip
  13. COPY . .
  14. RUN go build -o build/x-ui main.go
  15. RUN ./DockerInit.sh "$TARGETARCH"
  16. # ========================================================
  17. # Stage: Final Image of 3x-ui
  18. # ========================================================
  19. FROM alpine
  20. ENV TZ=Asia/Tehran
  21. WORKDIR /app
  22. RUN apk add --no-cache --update \
  23. ca-certificates \
  24. tzdata \
  25. fail2ban
  26. COPY --from=builder /app/build/ /app/
  27. COPY --from=builder /app/DockerEntrypoint.sh /app/
  28. COPY --from=builder /app/x-ui.sh /usr/bin/x-ui
  29. # Configure fail2ban
  30. RUN rm -f /etc/fail2ban/jail.d/alpine-ssh.conf \
  31. && cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local \
  32. && sed -i "s/^\[ssh\]$/&\nenabled = false/" /etc/fail2ban/jail.local
  33. RUN chmod +x \
  34. /app/DockerEntrypoint.sh \
  35. /app/x-ui \
  36. /usr/bin/x-ui
  37. VOLUME [ "/etc/x-ui" ]
  38. ENTRYPOINT [ "/app/DockerEntrypoint.sh" ]