mirror of
https://github.com/itdoginfo/allow-domains.git
synced 2025-04-13 01:09:08 +00:00
Properly use multi-stage build
This commit is contained in:
parent
7d859ba521
commit
08bfc1cc06
2 changed files with 13 additions and 24 deletions
20
Dockerfile
20
Dockerfile
|
@ -1,25 +1,21 @@
|
|||
FROM ghcr.io/sagernet/sing-box:v1.10.7 AS sing-box
|
||||
|
||||
FROM golang:1.23.1-alpine3.20 AS golang
|
||||
FROM golang:1.23.5-alpine3.21 AS go-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY xray-geosite/. /app
|
||||
|
||||
RUN go build -o geosite-compiler
|
||||
|
||||
FROM python:3.10.16-alpine3.21
|
||||
|
||||
COPY --from=sing-box /usr/local/bin/sing-box /bin/sing-box
|
||||
|
||||
COPY --from=golang /usr/local/go /usr/local/go
|
||||
|
||||
ENV GOROOT=/usr/local/go
|
||||
|
||||
ENV PATH="/usr/local/go/bin:${PATH}"
|
||||
COPY --from=go-builder /app/geosite-compiler /bin/geosite-compiler
|
||||
|
||||
RUN pip install --no-cache-dir tldextract
|
||||
|
||||
COPY xray-geosite /app/xray-geosite
|
||||
|
||||
WORKDIR /app/xray-geosite
|
||||
|
||||
RUN go mod download
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY convert.py /app/convert.py
|
||||
|
|
17
convert.py
17
convert.py
|
@ -307,8 +307,7 @@ def generate_srs_subnets(input_file, output_json_directory='JSON', compiled_outp
|
|||
print(f"Compile error {output_file_path}: {e}")
|
||||
|
||||
def prepare_dat_domains(domains_or_dirs, output_name):
|
||||
compiler_directory = 'xray-geosite'
|
||||
output_lists_directory = os.path.join(compiler_directory, 'data')
|
||||
output_lists_directory = 'data'
|
||||
|
||||
os.makedirs(output_lists_directory, exist_ok=True)
|
||||
|
||||
|
@ -330,19 +329,13 @@ def prepare_dat_domains(domains_or_dirs, output_name):
|
|||
with open(output_file_path, 'w', encoding='utf-8') as file:
|
||||
file.writelines(f"{name}\n" for name in extracted_domains)
|
||||
|
||||
def generate_dat_domains(compiled_output_directory='DAT'):
|
||||
working_directory = os.getcwd()
|
||||
compiler_directory = os.path.join(working_directory, 'xray-geosite')
|
||||
data_path = os.path.join(compiler_directory, 'data')
|
||||
output_directory = os.path.abspath(compiled_output_directory)
|
||||
|
||||
os.makedirs(compiled_output_directory, exist_ok=True)
|
||||
def generate_dat_domains(output_name='geosite.dat', output_directory='DAT'):
|
||||
os.makedirs(output_directory, exist_ok=True)
|
||||
|
||||
try:
|
||||
subprocess.run(
|
||||
["go", "run", compiler_directory, f"--datapath={data_path}", "--outputname=geosite.dat", f"--outputdir={output_directory}"],
|
||||
check=True,
|
||||
cwd=compiler_directory
|
||||
["geosite-compiler", f"-outputname={output_name}", f"-outputdir={output_directory}"],
|
||||
check=True
|
||||
)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Compile error geosite.dat: {e}")
|
||||
|
|
Loading…
Add table
Reference in a new issue