update cdn docker
This commit is contained in:
1 parent
efbd3ecf52
commit
56ff4ca63b
2 files changed
+51
-24
No files matched your search
+47
-20
@@ -1,38 +1,65 @@
|
|||||||
|
# Dockerfile
|
||||||
FROM python:3.12-slim
|
FROM python:3.12-slim
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
# Build-time args
|
||||||
PYTHONUNBUFFERED=1 \
|
ARG PASSWORD
|
||||||
PIP_NO_CACHE_DIR=1 \
|
|
||||||
DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# System deps: exiftool + sshd + bash (sqlite CLI not required for Python sqlite3)
|
# Prevent interactive prompts & set default DB path (optional, if app uses it)
|
||||||
RUN apt-get update \
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
&& apt-get install -y --no-install-recommends \
|
ENV DB_PATH=/data/app.db
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
PIP_NO_CACHE_DIR=1
|
||||||
|
|
||||||
|
# Install packages we need (exiftool, sqlite3, sshd, build tools, editor)
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
libimage-exiftool-perl \
|
libimage-exiftool-perl \
|
||||||
|
sqlite3 \
|
||||||
openssh-server \
|
openssh-server \
|
||||||
|
build-essential \
|
||||||
bash \
|
bash \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
nano \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Unprivileged user for the app / SSH
|
# Create an unprivileged user for running the app / SSH access
|
||||||
RUN useradd -m -d /home/ctfuser -s /bin/bash ctfuser
|
RUN useradd -m -d /home/ctfuser -s /bin/bash ctfuser \
|
||||||
|
&& if [ -n "${PASSWORD}" ]; then echo "ctfuser:${PASSWORD}" | chpasswd; fi
|
||||||
|
|
||||||
# SSH minimal setup
|
# Copy application and requirements
|
||||||
RUN mkdir -p /run/sshd && chmod 755 /run/sshd && ssh-keygen -A
|
COPY chall/requirements.txt /app/
|
||||||
|
RUN pip install --no-cache-dir -r /app/requirements.txt
|
||||||
|
|
||||||
COPY chall/requirements.txt .
|
COPY chall/ .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
COPY /chall /app
|
# Ensure entrypoint exists and is executable (keeps your existing entrypoint.sh)
|
||||||
|
RUN chmod +x /app/entrypoint.sh || true
|
||||||
|
|
||||||
RUN chmod +x /app/entrypoint.sh && mkdir -p /app/uploads && chmod 755 /app/uploads
|
# Create needed directories and set permissions
|
||||||
|
RUN mkdir -p /data /app/uploads /run/sshd /notes \
|
||||||
|
&& chown -R ctfuser:ctfuser /app /app/uploads /notes \
|
||||||
|
&& chmod 755 /app \
|
||||||
|
&& chmod 777 /app/uploads
|
||||||
|
# (intentionally NOT chowning /data here; we’ll fix /data at runtime in case it’s a bind mount)
|
||||||
|
|
||||||
RUN mkdir -p /data /app/uploads /run/sshd \
|
# Create the flag file with safe perms (will be overwritten at runtime if FLAG is set)
|
||||||
&& chown -R ctfuser:ctfuser /app /app/uploads /data \
|
RUN touch /flag.txt && chown root:root /flag.txt && chmod 644 /flag.txt
|
||||||
&& chmod 755 /app
|
|
||||||
|
|
||||||
|
# Configure basic sshd options
|
||||||
|
RUN echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && \
|
||||||
|
echo "PermitRootLogin no" >> /etc/ssh/sshd_config && \
|
||||||
|
echo "AllowUsers ctfuser" >> /etc/ssh/sshd_config && \
|
||||||
|
echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
# Generate host keys and make sure /run/sshd exists
|
||||||
|
RUN ssh-keygen -A || true
|
||||||
|
RUN mkdir -p /run/sshd && chmod 755 /run/sshd
|
||||||
|
|
||||||
|
# Expose app and ssh ports
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
EXPOSE 22
|
EXPOSE 22
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/bash", "/app/entrypoint.sh"]
|
USER root
|
||||||
|
CMD ["/app/entrypoint.sh"]
|
||||||
@@ -3,13 +3,13 @@ services:
|
|||||||
cdn_services:
|
cdn_services:
|
||||||
container_name: cdn_container
|
container_name: cdn_container
|
||||||
hostname: cdn
|
hostname: cdn
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
args:
|
||||||
|
- PASSWORD=root
|
||||||
ports:
|
ports:
|
||||||
- "4500:8000" # app
|
- "4500:8000" # app
|
||||||
- "4522:22" # ssh
|
- "4522:22" # ssh
|
||||||
environment:
|
environment:
|
||||||
SECRET_KEY: "c75f1259a4c95bb31563405d488d7bf9c0eaf4d562fd13557624f8e18eb5cfff"
|
SECRET_KEY: "c75f1259a4c95bb31563405d488d7bf9c0eaf4d562fd13557624f8e18eb5cfff"
|
||||||
# Optional: set SSH password for ctfuser at runtime
|
|
||||||
SSH_PASSWORD: "root"
|
|
||||||
# Optional: override if your app reads it
|
|
||||||
restart: always
|
restart: always
|
||||||
Reference in new issue
Block a user