aboutsummaryrefslogtreecommitdiff
path: root/Dockerfile.debian
diff options
context:
space:
mode:
Diffstat (limited to 'Dockerfile.debian')
-rw-r--r--Dockerfile.debian50
1 files changed, 50 insertions, 0 deletions
diff --git a/Dockerfile.debian b/Dockerfile.debian
new file mode 100644
index 0000000..be25622
--- /dev/null
+++ b/Dockerfile.debian
@@ -0,0 +1,50 @@
+# This Dockerfile sets up a simple SSH server for hosting git repositories. It installs the necessary packages, creates the required directories, and configures SSH to allow access using authorized keys.
+
+# Start with a base Debian image
+FROM debian:13.4
+
+# Install dependencies and clean up apt cache to reduce image size
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ openssh-server \
+ git \
+ cron \
+ && rm -rf /var/lib/apt/lists/*
+
+# Create the privilage separation directory as openssh-server post-install script doesn't do it in docker build context
+RUN mkdir -p /var/run/sshd
+
+# Create a git user and set up the home directory
+RUN useradd -m -s /bin/bash git
+
+# Create the repositories directory and set appropriate permissions
+RUN mkdir -p /repositories && chown git:git /repositories
+
+# Disallow password authentication for security reasons
+RUN echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
+
+# Copy the entrypoint script into the container
+COPY entrypoint.bash /
+
+# Copy cron jobs
+COPY etc/cron.d/* /etc/cron.d/
+
+# Set appropriate permissions for the cron jobs
+RUN chmod 0644 /etc/cron.d/*
+
+# Copy scripts
+COPY scripts/* /scripts/
+
+# Set appropriate permissions for the scripts
+RUN chmod +x /scripts/*
+
+# Copy git home overlay
+COPY home/git/* /home/git/
+
+# Make the entrypoint script executable
+RUN chmod +x /entrypoint.bash
+
+# Expose port 22 for SSH access
+EXPOSE 22
+
+# Define our entrypoint
+ENTRYPOINT [ "/entrypoint.bash" ] \ No newline at end of file