Skip to content

Commit

Permalink
Merge pull request #10 from bryanlatten/feature-convenience-scripts
Browse files Browse the repository at this point in the history
Scripts: added clean and security_updates conveniences
  • Loading branch information
bryanlatten authored Nov 11, 2016
2 parents 9b89e6c + 845979c commit 195e1c2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ ENV SIGNAL_BUILD_STOP=99 \
S6_VERSION=v1.18.1.5 \
GOSS_VERSION=v0.2.4

# Upgrade base packages, then clean packaging leftover
RUN apt-get update && \
apt-get upgrade -yqq && \
# Ensure scripts are available for use in next command
COPY ./container/root/security_updates.sh / \
./container/root/clean.sh /

# - Upgrade base security packages, then clean packaging leftover
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
/bin/bash -e /security_updates.sh && \
apt-get install -yqq \
curl \
&& \
# Add S6 for zombie reaping, boot-time coordination, signal transformation/distribution
curl -L https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz -o /tmp/s6.tar.gz && \
tar xzf /tmp/s6.tar.gz -C / && \
rm /tmp/s6.tar.gz && \
# Add goss for local, serverspec-like testing \
# Add goss for local, serverspec-like testing
curl -L https://github.com/aelsabbahy/goss/releases/download/${GOSS_VERSION}/goss-linux-amd64 -o /usr/local/bin/goss && \
chmod +x /usr/local/bin/goss && \
apt-get remove --purge -yq \
curl \
&& \
apt-get autoclean -y && \
apt-get autoremove -y && \
rm -rf /var/lib/{cache,log}/ && \
rm -rf /var/lib/apt/lists/*.lz4 && \
rm -rf /tmp/* /var/tmp/*
/bin/bash -e /clean.sh

# Overlay the root filesystem from this repo
COPY ./container/root /
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ Provides base OS, patches and stable nginx for quick and easy spinup.
### Expectations

To add a service to be monitored, simply create a service script: https://github.com/just-containers/s6-overlay#writing-a-service-script
For programmatic switches, create the service in `/etc/services-available`, and symlink to `/etc/services.d` to enable
For programmatic switches, create the service in `/etc/services-available`, and symlink to `/etc/services.d` to enable

### Security

For Ubuntu-based variants, a convenience script is provided for security-only package updates. To run:
`/bin/bash -e /security_updates.sh`


### Environment Variables

Expand Down
12 changes: 12 additions & 0 deletions container/root/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -e

#-------------------------------------------------------------------
# Performs cleanup, ensure unnecessary packages and package lists
# are safely removed, without triggering Docker AUFS permission bug
#-------------------------------------------------------------------

apt-get autoclean -y && \
apt-get autoremove -y && \
rm -rf /var/lib/{cache,log}/ && \
rm -rf /var/lib/apt/lists/*.lz4 && \
rm -rf /tmp/* /var/tmp/*
11 changes: 11 additions & 0 deletions container/root/security_updates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

#-------------------------------------------------------------------
# Upgrade just the packages listed as security, without affecting
# any subsequent usages of apt-get
#-------------------------------------------------------------------

apt-get update && \
grep security /etc/apt/sources.list > /tmp/security.list && \
apt-get upgrade -oDir::Etc::Sourcelist=/tmp/security.list -yq && \
rm /tmp/security.list

0 comments on commit 195e1c2

Please sign in to comment.