Merge branch 'master' of github.com:bryanhong/docker-aptly
This commit is contained in:
commit
526b418ae2
39
Dockerfile
39
Dockerfile
|
@ -28,32 +28,39 @@ RUN echo "deb-src http://nginx.org/packages/ubuntu/ trusty nginx" >> /etc/apt/so
|
||||||
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
|
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
|
||||||
|
|
||||||
# Update APT repository and install packages
|
# Update APT repository and install packages
|
||||||
RUN apt-get -q update \
|
RUN apt-get -q update \
|
||||||
&& apt-get -y install aptly \
|
&& apt-get -y install aptly \
|
||||||
bzip2 \
|
bash-completion \
|
||||||
xz-utils \
|
bzip2 \
|
||||||
graphviz \
|
gnupg \
|
||||||
gnupg \
|
gpgv \
|
||||||
gpgv \
|
graphviz \
|
||||||
supervisor \
|
supervisor \
|
||||||
nginx
|
nginx \
|
||||||
|
wget \
|
||||||
# Install GPG Generator
|
xz-utils
|
||||||
COPY assets/gpg_batch.sh /opt/gpg_batch.sh
|
|
||||||
|
|
||||||
# Install Aptly Configuration
|
# Install Aptly Configuration
|
||||||
COPY assets/aptly.conf /etc/aptly.conf
|
COPY assets/aptly.conf /etc/aptly.conf
|
||||||
|
|
||||||
# Install Mirror Update Script
|
# Enable Aptly Bash completions
|
||||||
COPY assets/update_mirror.sh /opt/update_mirror.sh
|
RUN wget https://github.com/aptly-dev/aptly-bash-completion/raw/master/aptly \
|
||||||
|
-O /etc/bash_completion.d/aptly \
|
||||||
|
&& echo "if ! shopt -oq posix; then\n\
|
||||||
|
if [ -f /usr/share/bash-completion/bash_completion ]; then\n\
|
||||||
|
. /usr/share/bash-completion/bash_completion\n\
|
||||||
|
elif [ -f /etc/bash_completion ]; then\n\
|
||||||
|
. /etc/bash_completion\n\
|
||||||
|
fi\n\
|
||||||
|
fi" >> /etc/bash.bashrc
|
||||||
|
|
||||||
# Install Nginx Config
|
# Install Nginx Config
|
||||||
COPY assets/nginx.conf.sh /opt/nginx.conf.sh
|
COPY assets/nginx.conf.sh /opt/nginx.conf.sh
|
||||||
COPY assets/supervisord.nginx.conf /etc/supervisor/conf.d/nginx.conf
|
COPY assets/supervisord.nginx.conf /etc/supervisor/conf.d/nginx.conf
|
||||||
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
|
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
|
||||||
|
|
||||||
# Install Startup script
|
# Install scripts
|
||||||
COPY assets/startup.sh /opt/startup.sh
|
COPY assets/*.sh /opt/
|
||||||
|
|
||||||
# Bind mount location
|
# Bind mount location
|
||||||
VOLUME [ "/opt/aptly" ]
|
VOLUME [ "/opt/aptly" ]
|
||||||
|
|
|
@ -3,41 +3,58 @@ set -e
|
||||||
|
|
||||||
# Automate the initial creation and update of an Ubuntu package mirror in aptly
|
# Automate the initial creation and update of an Ubuntu package mirror in aptly
|
||||||
|
|
||||||
|
# The variables (as set below) will create a mirror of the Ubuntu Trusty repo
|
||||||
|
# with just the main component, you can add other components like restricted
|
||||||
|
# universe etc by adding to the array (separated by spaces).
|
||||||
|
|
||||||
|
# For more detail about each of the variables below refer to:
|
||||||
|
# https://help.ubuntu.com/community/Repositories/CommandLine
|
||||||
|
|
||||||
UBUNTU_RELEASE=trusty
|
UBUNTU_RELEASE=trusty
|
||||||
UPSTREAM_URL="http://archive.ubuntu.com/ubuntu/"
|
UPSTREAM_URL="http://archive.ubuntu.com/ubuntu/"
|
||||||
|
COMPONENTS=( main )
|
||||||
REPOS=( ${UBUNTU_RELEASE} ${UBUNTU_RELEASE}-updates ${UBUNTU_RELEASE}-security )
|
REPOS=( ${UBUNTU_RELEASE} ${UBUNTU_RELEASE}-updates ${UBUNTU_RELEASE}-security )
|
||||||
|
|
||||||
# Create repository mirrors if they don't exist
|
# Create repository mirrors if they don't exist
|
||||||
set +e
|
set +e
|
||||||
for repo in ${REPOS[@]}; do
|
for component in ${COMPONENTS[@]}; do
|
||||||
aptly mirror list -raw | grep "^${repo}$"
|
for repo in ${REPOS[@]}; do
|
||||||
if [[ $? -ne 0 ]]; then
|
aptly mirror list -raw | grep "^${repo}-${component}$"
|
||||||
echo "Creating mirror of ${repo} repository."
|
if [[ $? -ne 0 ]]; then
|
||||||
aptly mirror create \
|
echo "Creating mirror of ${repo}-${component} repository."
|
||||||
-architectures=amd64 ${repo} ${UPSTREAM_URL} ${repo} main
|
aptly mirror create \
|
||||||
fi
|
-architectures=amd64 ${repo}-${component} ${UPSTREAM_URL} ${repo} ${component}
|
||||||
|
fi
|
||||||
|
done
|
||||||
done
|
done
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Update all repository mirrors
|
# Update all repository mirrors
|
||||||
for repo in ${REPOS[@]}; do
|
for component in ${COMPONENTS[@]}; do
|
||||||
echo "Updating ${repo} repository mirror.."
|
for repo in ${REPOS[@]}; do
|
||||||
aptly mirror update ${repo}
|
echo "Updating ${repo}-${component} repository mirror.."
|
||||||
|
aptly mirror update ${repo}-${component}
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# Create snapshots of updated repositories
|
# Create snapshots of updated repositories
|
||||||
for repo in ${REPOS[@]}; do
|
for component in ${COMPONENTS[@]}; do
|
||||||
echo "Creating snapshot of ${repo} repository mirror.."
|
for repo in ${REPOS[@]}; do
|
||||||
aptly snapshot create ${repo}-`date +%Y%m%d%H` from mirror ${repo}
|
echo "Creating snapshot of ${repo}-${component} repository mirror.."
|
||||||
|
SNAPSHOTARRAY+="${repo}-${component}-`date +%Y%m%d%H` "
|
||||||
|
aptly snapshot create ${repo}-${component}-`date +%Y%m%d%H` from mirror ${repo}-${component}
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo ${SNAPSHOTARRAY[@]}
|
||||||
|
|
||||||
|
#### I STOPPED HERE
|
||||||
|
|
||||||
# Merge snapshots into a single snapshot with updates applied
|
# Merge snapshots into a single snapshot with updates applied
|
||||||
echo "Merging snapshots into one.."
|
echo "Merging snapshots into one.."
|
||||||
aptly snapshot merge -latest \
|
aptly snapshot merge -latest \
|
||||||
${UBUNTU_RELEASE}-merged-`date +%Y%m%d%H` \
|
${UBUNTU_RELEASE}-merged-`date +%Y%m%d%H` \
|
||||||
${UBUNTU_RELEASE}-`date +%Y%m%d%H` \
|
${SNAPSHOTARRAY[@]}
|
||||||
${UBUNTU_RELEASE}-updates-`date +%Y%m%d%H` \
|
|
||||||
${UBUNTU_RELEASE}-security-`date +%Y%m%d%H`
|
|
||||||
|
|
||||||
# Publish the latest merged snapshot
|
# Publish the latest merged snapshot
|
||||||
set +e
|
set +e
|
||||||
|
|
Loading…
Reference in New Issue