Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add installation via docker-compose #182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
FROM golang:latest AS builder
WORKDIR /root
FROM ubuntu:22.04

WORKDIR /

ARG USERNAME=vpnuser
ARG PASSWORD=qweasdQWEASD
ARG PORT=9007

RUN apt-get update && apt-get install wget curl tar -y

COPY . .
RUN go build main.go
RUN chmod +x entrypoint.sh

RUN apt-get update && \
apt-get install -yq tzdata && \
ln -fs /usr/share/zoneinfo/Asia/Tehran /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata

WORKDIR /usr/local

RUN wget -N --no-check-certificate -O /usr/local/x-ui-linux-amd64.tar.gz https://github.com/vaxilu/x-ui/releases/download/0.3.2/x-ui-linux-amd64.tar.gz
RUN tar zxvf x-ui-linux-amd64.tar.gz
RUN rm x-ui-linux-amd64.tar.gz -f
RUN chmod +x /usr/local/x-ui/x-ui
RUN chmod +x /usr/local/x-ui/bin/xray-linux-amd64

RUN wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/vaxilu/x-ui/main/x-ui.sh
RUN chmod +x /usr/local/x-ui/x-ui.sh
RUN chmod +x /usr/bin/x-ui

RUN /usr/local/x-ui/x-ui setting -username $USERNAME -password $PASSWORD
RUN /usr/local/x-ui/x-ui setting -port $PORT

WORKDIR /

FROM debian:11-slim
RUN apt-get update && apt-get install -y --no-install-recommends -y ca-certificates \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /root
COPY --from=builder /root/main /root/x-ui
COPY bin/. /root/bin/.
VOLUME [ "/etc/x-ui" ]
CMD [ "./x-ui" ]
CMD ["./entrypoint.sh"]
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.8"
services:
vpn:
build:
context: .
args:
- USERNAME=vpnuser
- PASSWORD=qweasdQWEASD
- PORT=9007
network_mode: host
environment:
- TZ=Asia/Tehran
restart: unless-stopped
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

set xe
cd /usr/local/x-ui && ./x-ui