3x-ui/Dockerfile

108 lines
2.5 KiB
Text
Raw Normal View History

# ========================================================
# Stage: Builder
# ========================================================
FROM golang:1.22-alpine AS builder
2023-05-07 16:59:37 +00:00
WORKDIR /app
ARG TARGETARCH
RUN apk --no-cache --update add \
build-base \
gcc \
wget \
unzip
2023-05-07 16:59:37 +00:00
COPY . .
2023-05-08 02:22:48 +00:00
2024-01-27 09:26:10 +00:00
ENV CGO_ENABLED=1
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
RUN go build -o build/x-ui main.go
RUN ./DockerInit.sh "$TARGETARCH"
2023-05-08 02:22:48 +00:00
# ========================================================
# Stage: Final Image of 3x-ui
# ========================================================
FROM alpine
ENV TZ=Asia/Tehran
2023-05-07 16:59:37 +00:00
WORKDIR /app
2023-05-08 02:22:48 +00:00
RUN apk add --no-cache --update \
ca-certificates \
tzdata \
2024-01-27 09:26:10 +00:00
fail2ban \
bash \
2024-08-24 04:32:25 +00:00
bash-completion \
2024-08-24 17:08:43 +00:00
bc \
supercronic \
2024-08-24 04:32:25 +00:00
curl \
2024-08-24 17:08:43 +00:00
gawk \
git \
htop \
iptables \
iperf3 \
iproute2 \
2024-08-24 17:08:43 +00:00
jq \
nano \
netcat-openbsd \
2024-08-24 04:32:25 +00:00
nginx \
2024-08-24 17:08:43 +00:00
socat \
sqlite \
tcptraceroute \
tcpdump \
tmux \
unzip \
wget \
python3 \
py3-pip \
2024-08-23 16:07:49 +00:00
py3-psutil \
2024-08-23 16:10:29 +00:00
py3-curl \
2024-08-23 16:07:49 +00:00
py3-pysocks \
py3-dotenv \
py3-cloudflare \
py3-virtualenv
2024-08-24 17:15:52 +00:00
# openssh \
2024-08-24 17:08:43 +00:00
# nginx-mod-stream \
2024-08-24 04:32:25 +00:00
SHELL ["/bin/bash", "-c"]
2023-05-07 16:59:37 +00:00
2024-08-25 09:44:06 +00:00
# Copy custom nginx configuration file to the http.d directory
COPY ./nginx_http.conf /etc/nginx/http.d/
2024-08-24 17:15:52 +00:00
## Set up the SSH keys from an environment variable
#ENV AUTHORIZED_KEYS=""
#RUN echo "${AUTHORIZED_KEYS}" > /root/.ssh/authorized_keys && \
# chmod 600 /root/.ssh/authorized_keys
## Configure SSH daemon
#RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
# sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
2024-08-24 17:08:43 +00:00
# # Configure SSH server
# RUN mkdir /var/run/sshd && \
# echo 'root:rootpassword' | chpasswd && \
# sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
# sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
# ssh-keygen -A
2024-01-27 09:26:10 +00:00
COPY --from=builder /app/build/ /app/
COPY --from=builder /app/DockerEntrypoint.sh /app/
COPY --from=builder /app/x-ui.sh /usr/bin/x-ui
# Configure fail2ban
RUN rm -f /etc/fail2ban/jail.d/alpine-ssh.conf \
&& cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local \
2023-07-20 18:24:51 +00:00
&& sed -i "s/^\[ssh\]$/&\nenabled = false/" /etc/fail2ban/jail.local \
&& sed -i "s/^\[sshd\]$/&\nenabled = false/" /etc/fail2ban/jail.local \
&& sed -i "s/#allowipv6 = auto/allowipv6 = auto/g" /etc/fail2ban/fail2ban.conf
RUN chmod +x \
/app/DockerEntrypoint.sh \
/app/x-ui \
/usr/bin/x-ui
VOLUME [ "/etc/x-ui" ]
2024-01-27 09:26:10 +00:00
CMD [ "./x-ui" ]
ENTRYPOINT [ "/app/DockerEntrypoint.sh" ]