1
0

Dockerfile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # ========================================================
  2. # Stage: Builder
  3. # ========================================================
  4. FROM --platform=$BUILDPLATFORM golang:1.21-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. && sed -i "s/^\[sshd\]$/&\nenabled = false/" /etc/fail2ban/jail.local \
  34. && sed -i "s/#allowipv6 = auto/allowipv6 = auto/g" /etc/fail2ban/fail2ban.conf
  35. RUN chmod +x \
  36. /app/DockerEntrypoint.sh \
  37. /app/x-ui \
  38. /usr/bin/x-ui
  39. VOLUME [ "/etc/x-ui" ]
  40. ENTRYPOINT [ "/app/DockerEntrypoint.sh" ]