forked from rccypher/RapidCopy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
148 lines (125 loc) · 4.13 KB
/
Dockerfile
File metadata and controls
148 lines (125 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# RapidCopy - Single-stage local build Dockerfile
# Usage: docker build -t rapidcopy:latest .
# ============================================
# Stage 1: Build Angular frontend
# ============================================
FROM node:18-slim AS angular-builder
WORKDIR /app
COPY src/angular/package*.json ./
RUN npm install
COPY src/angular/src ./src
COPY src/angular/public ./public
COPY src/angular/angular.json ./
COPY src/angular/tsconfig*.json ./
RUN npx ng build --configuration production --output-path /build/html
# ============================================
# Stage 2: Build scanfs binary
# ============================================
FROM python:3.11-slim-bullseye AS scanfs-builder
RUN apt-get update && apt-get install -y \
binutils \
zlib1g-dev \
gcc \
build-essential \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir pipx && \
pipx install poetry && \
pipx ensurepath
ENV PATH="/root/.local/bin:$PATH"
RUN poetry config virtualenvs.create false
COPY src/python/pyproject.toml src/python/poetry.lock /app/
WORKDIR /app
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN poetry install --only main --no-root && \
poetry install --only dev --no-root
COPY src/python /python
RUN pyinstaller /python/scan_fs.py \
-y \
--onefile \
-p /python \
--distpath /build \
--workpath /tmp/work \
--specpath /tmp \
--name scanfs
# ============================================
# Stage 3: Runtime image
# ============================================
FROM python:3.11-slim-bullseye AS runtime
# Install runtime dependencies
# Handle both old (sources.list) and new (sources.list.d/*.sources) Debian formats
RUN if [ -f /etc/apt/sources.list ]; then \
sed -i -e's/ main/ main contrib non-free/g' /etc/apt/sources.list; \
elif [ -f /etc/apt/sources.list.d/debian.sources ]; then \
sed -i 's/Components: main/Components: main contrib non-free non-free-firmware/g' /etc/apt/sources.list.d/debian.sources; \
fi && \
apt-get update && \
apt-get install -y \
gcc \
libssl-dev \
lftp \
openssh-client \
p7zip \
p7zip-full \
bzip2 \
curl \
libnss-wrapper \
libxml2-dev libxslt-dev libffi-dev \
zlib1g-dev \
# Network mount support (NFS/SMB/CIFS)
nfs-common \
cifs-utils \
keyutils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Poetry
RUN pip install --no-cache-dir pipx && \
pipx install poetry && \
pipx ensurepath
ENV PATH="/root/.local/bin:$PATH"
RUN poetry config virtualenvs.create false
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
# Install Python dependencies
COPY src/python/pyproject.toml src/python/poetry.lock /app/python/
RUN cd /app/python && poetry install --only main --no-root
# Copy Python source
COPY src/python /app/python
# Copy built artifacts from previous stages
COPY --from=angular-builder /build/html/browser /app/html
COPY --from=scanfs-builder /build/scanfs /app/scanfs
# Copy helper scripts
COPY src/docker/build/docker-image/setup_default_config.sh /scripts/
COPY src/docker/build/docker-image/run_as_user /usr/local/bin/
COPY src/docker/build/docker-image/ssh /usr/local/sbin/
COPY src/docker/build/docker-image/scp /usr/local/sbin/
RUN chmod a+x /usr/local/bin/run_as_user && \
chmod a+x /usr/local/sbin/ssh && \
chmod a+x /usr/local/sbin/scp
# Disable SSH known hosts prompt
RUN mkdir -p /root/.ssh && \
echo "StrictHostKeyChecking no\nUserKnownHostsFile /dev/null" > /root/.ssh/config
# Create non-root user
RUN groupadd -g 1000 rapidcopy && \
useradd -r -u 1000 -g rapidcopy rapidcopy && \
mkdir /config && \
mkdir /downloads && \
mkdir /mounts && \
mkdir /logs && \
chown rapidcopy:rapidcopy /config && \
chown rapidcopy:rapidcopy /downloads && \
chown rapidcopy:rapidcopy /mounts && \
chown rapidcopy:rapidcopy /logs
USER rapidcopy
# Setup default config
RUN /scripts/setup_default_config.sh
CMD [ \
"python", \
"/app/python/rapidcopy.py", \
"-c", "/config", \
"--html", "/app/html", \
"--scanfs", "/app/scanfs", \
"--logdir", "/logs" \
]
EXPOSE 8805