Test docker image, basic functionality
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# Git
|
||||
.git/
|
||||
.gitignore
|
||||
|
||||
# Python cache
|
||||
*.pyc
|
||||
__pycache__/
|
||||
*.pyo
|
||||
*.pyd
|
||||
|
||||
# Build artifacts
|
||||
build/
|
||||
dist/
|
||||
*.egg-info/
|
||||
.eggs/
|
||||
|
||||
# Virtual environments
|
||||
.venv
|
||||
venv/
|
||||
env/
|
||||
ENV/
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
|
||||
# License (not needed for installation)
|
||||
LICENSE
|
||||
|
||||
# Docker files (not needed in build context)
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
|
||||
# Local test files
|
||||
*.mp3
|
||||
*.flac
|
||||
*.wav
|
||||
*.txt
|
||||
*.log
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
FROM python:3.13-slim
|
||||
|
||||
# Install FFmpeg and dependencies (gosu will be downloaded separately)
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends ffmpeg ca-certificates wget gpg && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install gosu (lightweight tool for dropping privileges)
|
||||
RUN set -eux; \
|
||||
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
|
||||
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.17/gosu-$dpkgArch"; \
|
||||
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.17/gosu-$dpkgArch.asc"; \
|
||||
export GNUPGHOME="$(mktemp -d)"; \
|
||||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
|
||||
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
|
||||
gpgconf --kill all; \
|
||||
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
|
||||
chmod +x /usr/local/bin/gosu; \
|
||||
gosu --version
|
||||
|
||||
# Set Python environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package metadata and source code
|
||||
COPY setup.py pyproject.toml README.md ./
|
||||
COPY audio_splitter/ ./audio_splitter/
|
||||
|
||||
# Install the package
|
||||
RUN pip install --no-cache-dir .
|
||||
|
||||
# Create a non-root user with UID 1000
|
||||
RUN addgroup --system --gid 1000 appgroup && \
|
||||
adduser --system --uid 1000 --ingroup appgroup appuser
|
||||
|
||||
# Change ownership of /app to the container user (so it can write there if needed)
|
||||
RUN chown -R appuser:appgroup /app
|
||||
|
||||
# Copy the entrypoint script
|
||||
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
# Set the entrypoint
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
|
||||
# Default command (shows help if no arguments)
|
||||
CMD ["audio_splitter", "--help"]
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Check if we are running as root (default)
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
# If /data is a directory, change its ownership to the container user
|
||||
if [ -d "/data" ]; then
|
||||
echo "Setting ownership of /data to appuser:appgroup"
|
||||
chown -R appuser:appgroup /data
|
||||
fi
|
||||
|
||||
# Drop privileges and run the command using gosu
|
||||
exec gosu appuser "$@"
|
||||
else
|
||||
# If not root, just run the command directly
|
||||
exec "$@"
|
||||
fi
|
||||
Reference in New Issue
Block a user