Commit 58b3e7ee authored by Piotr Gawron's avatar Piotr Gawron
Browse files

initial commit

parents
#This docker image is based on https://github.com/glenux/docker-debian-repository. Original docker is out of date and doesn't work anymore.
FROM debian:latest
MAINTAINER Piotr Gawron <piotr.gawron@uni.lu>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
# Install supervisor for managing services
RUN apt-get install -q -y supervisor cron openssh-server pwgen reprepro screen vim-tiny nginx
# Configure cron
# Install cron for managing regular tasks
RUN sed -i 's/\(session *required *pam_loginuid.so\)/#\1/' /etc/pam.d/cron
# Install ssh (run/stop to create required directories)
RUN mkdir /var/run/sshd
#RUN service ssh start ; sleep 1
RUN service ssh stop
RUN sed -i '/PermitRootLogin/c\PermitRootLogin yes' /etc/ssh/sshd_config
RUN sed -i '/PermitEmptyPasswords/c\PermitEmptyPasswords yes' /etc/ssh/sshd_config
RUN sed -i '/UsePAM yes/c\#UsePAM yes' /etc/ssh/sshd_config
# Configure reprepro
ADD scripts/reprepro-import.sh /usr/local/sbin/reprepro-import
RUN chmod 755 /usr/local/sbin/reprepro-import
RUN mkdir -p /var/lib/reprepro/conf
ADD configs/reprepro-distributions /var/lib/reprepro/conf/distributions
# Configure nginx
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN rm -f /etc/nginx/sites-enabled/default
ADD configs/nginx-default.conf /etc/nginx/sites-enabled/default
# Setup root access
RUN passwd -d root
# Configure supervisor
RUN service supervisor stop
ADD configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ADD configs/supervisor-cron.conf /etc/supervisor/conf.d/cron.conf
ADD configs/supervisor-ssh.conf /etc/supervisor/conf.d/ssh.conf
ADD configs/supervisor-nginx.conf /etc/supervisor/conf.d/nginx.conf
# Finalize
ENV DEBIAN_FRONTEND newt
ADD scripts/start.sh /usr/local/sbin/start
RUN chmod 755 /usr/local/sbin/start
VOLUME ["/docker/keys", "/docker/incoming", "/repository"]
EXPOSE 80
EXPOSE 22
CMD ["/usr/local/sbin/start"]
Copyright (c) The Regents of the University of California.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Debian-repository for Docker
============================
This project is based on https://github.com/glenux/docker-debian-repository [(Glenn Y. Rolland, aka Glenux)](http://www.glenux.net). Original docker image is out of date and doesn't work anymore.
This project can be used as a local repository for publishing deb files for use with apt - especially usefull as a gitlab ci service.
This docker box provides an apt repository based on the tool reprepro.
The repository is served by an nginx server.
Usage
-----
### Running the box
Run with 22 and 80 ports opened. No authentication is needed for ssh access - it's very unsecure, but very convenient for gitlab ci service.
docker run -d -p 49160:22 -p 49161:80 piotrgawron/debian-repository
### Uploading packages
```
echo "PUT foobar_0.0.1_amd64.deb /docker/incoming" | sftp -o StrictHostKeyChecking=no -P 49160 user@localhost
```
You can trigger rebuilding repo indices by:
```
ssh -p 49160 root@localhost /usr/local/sbin/reprepro-import
```
Or you can wait a minute for cron job to do it automatically.
### Accessing the repository
Add the following line to your source list
deb http://localhost:49161/ unstable main contrib non-free
License
-------
It is free software, and may be redistributed under the terms specified in the LICENSE file.
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /repository/debian;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
autoindex on;
location / {
try_files $uri $uri/ =404;
}
}
Origin: Glenn Y. Rolland
Label: Glenux Truc
Suite: unstable
Codename: sid
Version: 3.1
Architectures: i386 amd64 powerpc source
Components: main non-free contrib
Description: Glenux.Net Repository Unstable
[program:cron]
command=/usr/sbin/cron -f
[program:nginx]
command=/usr/sbin/nginx
stdout_events_enabled=true
stderr_events_enabled=true
[program:ssh]
command=/usr/sbin/sshd -D
[supervisord]
nodaemon=true
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC19zZUOjrv/COz8v7J8LI4/kP/BI3xKDG4dsNxzW0ZGQw3ZC2dYZsvmOCNJJMbxzzFjwGzlfXoiqjDrFQ6aOZHrvudL29PE4/RYCn2DMZO5YwEnpkfXArPZ9pxpLbvY+tXReUF7+bRA56BDUEYYAVaP7QfLs1SFcLuHW9lBHEOrJD8oQWr7GvEVyVMRMOIEIngYDut3HwpKk1tweQk0GDG1JpBi4TUXEPQKIwP5aGpojLSM5w2/Q+0ohm4BKO9CFoLhL4Nptu57CuTcfSBoHt72Yg3dd9dVrao3vGRQiYmnxp3WUGGD//qzcRApHxSvoz20usfX/pDKks+f4UT+FUZ warbrain@dyction
#!/bin/sh
BASEDIR=/var/lib/reprepro
INCOMING=/docker/incoming
OUTDIR=/repository/debian
#
# Make sure we're in the apt/ directory
#
cd $INCOMING
cd ..
#set -x
reprepro --basedir $BASEDIR --outdir $OUTDIR createsymlinks unstable
#
# See if we found any new packages
#
found=0
for i in $INCOMING/*.deb; do
if [ -e $i ]; then
found=`expr $found + 1`
fi
done
#
# If we found none then exit
#
if [ "$found" -lt 1 ]; then
exit
fi
#
# Now import each new package that we *did* find
#
for i in $INCOMING/*.deb; do
reprepro -b $OUTDIR --confdir $BASEDIR/conf includedeb unstable $i
done
chown -R www-data:www-data $OUTDIR
#!/bin/sh
# Many thanks to John Fink <john.fink@gmail.com> for the
# inspiration and to his great work on docker-wordpress'
# reset root password
# let's create a user to SSH into
mkdir /home/user
useradd -d /home/user -s /bin/bash user
chown -R user /home/user
chown -R user /docker/incoming
#echo "user:docker" | chpasswd
#echo "ssh user password: docker"
passwd -d user
# pre-fill with SSH keys
echo "Pre-loading SSH keys from /docker/keys"
mkdir -p /home/user/.ssh
rm -f /home/user/.ssh/authorized_keys
for key in /docker/keys/*.pub ; do
echo "- adding key $key"
cat $key >> /home/user/.ssh/authorized_keys
done
chown -R user /home/user/.ssh
# load crontab for root
crontab <<EOF
* * * * * /usr/local/sbin/reprepro-import >> /var/log/reprepro.log
EOF
# run import once, to create the right directory structure
/usr/local/sbin/reprepro-import
supervisord -n
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment