Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
Add dockerspec variant
Browse files Browse the repository at this point in the history
  • Loading branch information
prehor committed Aug 1, 2017
1 parent d6c0b81 commit ee946cd
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 86 deletions.
50 changes: 38 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,75 @@ jobs:
command: |
docker version
- run:
name: Build and test latest Alpine Linux Docker image
name: Build and test latest Alpine Linux image
command: |
make ci-rebuild-and-test DOCKER_TEST_IMAGE=
make ci-build-and-test DOCKER_TEST_IMAGE=
- run:
name: Build and test development Alpine Linux Docker image
name: Build and test development Alpine Linux image
working_directory: devel
command: |
make ci-rebuild-and-test DOCKER_TEST_IMAGE=
make ci-build-and-test DOCKER_TEST_IMAGE=
- run:
name: Build and test latest CentOS Docker image
name: Build and test latest Dockerspec image
working_directory: dockerspec
command: |
make ci-build-and-test DOCKER_TEST_IMAGE=
- run:
name: Build and test development Dockerspec image
working_directory: dockerspec/devel
command: |
make ci-build-and-test DOCKER_TEST_IMAGE=
- run:
name: Build and test latest CentOS image
working_directory: centos
command: |
make ci-rebuild-and-test DOCKER_TEST_IMAGE=
make ci-build-and-test DOCKER_TEST_IMAGE=
- run:
name: Build and test development CentOS Docker image
name: Build and test development CentOS image
working_directory: centos/devel
command: |
make ci-rebuild-and-test DOCKER_TEST_IMAGE=
make ci-build-and-test DOCKER_TEST_IMAGE=
- deploy:
name: Push latest Alpine Linux Docker image to Docker Hub
name: Push latest Alpine Linux image to Docker Hub
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
docker login -u ${DOCKER_HUB_USER} -p ${DOCKER_HUB_PASSWD}
make docker-push
fi
- deploy:
name: Push development Alpine Linux Docker image to Docker Hub
name: Push development Alpine Linux image to Docker Hub
working_directory: devel
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
docker login -u ${DOCKER_HUB_USER} -p ${DOCKER_HUB_PASSWD}
make docker-push
fi
- deploy:
name: Push latest CentOS Docker image to Docker Hub
name: Push latest Dockerspec image to Docker Hub
working_directory: dockerspec
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
docker login -u ${DOCKER_HUB_USER} -p ${DOCKER_HUB_PASSWD}
make docker-push
fi
- deploy:
name: Push development Dockerspec image to Docker Hub
working_directory: dockerspec/devel
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
docker login -u ${DOCKER_HUB_USER} -p ${DOCKER_HUB_PASSWD}
make docker-push
fi
- deploy:
name: Push latest CentOS image to Docker Hub
working_directory: centos
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
docker login -u ${DOCKER_HUB_USER} -p ${DOCKER_HUB_PASSWD}
make docker-push
fi
- deploy:
name: Push development CentOS Docker image to Docker Hub
name: Push development CentOS image to Docker Hub
working_directory: centos/devel
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
Expand Down
4 changes: 0 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ spec

# Simple CA secrets
secrets

# Docker image variants
devel
centos
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# Auto detect text files and perform LF normalization
* text=auto

# Set GitHub Linguist languages
Dockerfile.* linguist-language=Dockerfile
93 changes: 68 additions & 25 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,89 @@ ARG BASEIMAGE_NAME
ARG BASEIMAGE_TAG
FROM ${BASEIMAGE_NAME}:${BASEIMAGE_TAG}

ARG BUILD_DATE
ARG VCS_REF

LABEL org.label-schema.build-date="${BUILD_DATE}"
LABEL org.label-schema.vcs-ref="${VCS_REF}"

RUN set -exo pipefail ; \
# Upgrade system
apk upgrade --no-cache ; \
# Install base image packages
apk add --no-cache \
bash \
ca-certificates \
curl \
jq \
libressl \
runit \
su-exec \
tini \
;

ARG DOCKER_IMAGE_NAME
ARG DOCKER_TAG
ARG DOCKER_DESCRIPTION
ARG DOCKER_PROJECT_URL
ARG BUILD_DATE
ARG GITHUB_URL
ARG VCS_REF

LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.name="${DOCKER_IMAGE_NAME}"
LABEL org.label-schema.version="${DOCKER_TAG}"
LABEL org.label-schema.description="${DOCKER_DESCRIPTION}"
LABEL org.label-schema.url="${DOCKER_PROJECT_URL}"
LABEL org.label-schema.vcs-url="${GITHUB_URL}"
LABEL org.label-schema.vcs-ref="${VCS_REF}"
LABEL org.label-schema.build-date="${BUILD_DATE}"

RUN set -ex \
# Upgrade system
&& apk upgrade --no-cache \
# Install base image packages
&& apk add --no-cache \
bash \
ca-certificates \
curl \
jq \
libressl \
runit \
su-exec \
tini \
;
ARG DOCKER_NAME
ARG DOCKER_VERSION

COPY config /
RUN set -ex \
&& chmod +x /docker-entrypoint.sh \
# Check custom bash config files
&& bash -i -l -c "true" \
;
RUN set -exo pipefail ; \
chmod +x /docker-entrypoint.sh ; \
#
# Install sicz/dockerspec software
#
if [ "${DOCKER_NAME}" = "dockerspec" ]; then \
# Install packages needed to runn the tests
apk add --no-cache \
git \
make \
openssh-client \
python2 \
ruby \
ruby-io-console \
ruby-irb \
ruby-rdoc \
; \
# Install Docker
curl -fL "https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz" \
| tar xfz - -C /tmp ; \
mv /tmp/docker/* /usr/bin ; \
rm -rf /tmp/docker ; \
docker --version ; \
# Install Docker Compose
apk add --no-cache --virtual .build-dependencies \
py2-pip \
; \
pip install --upgrade pip ; \
pip install docker-compose ; \
apk del --no-cache .build-dependencies ; \
docker-compose --version ; \
# Install rspec and serverspec
gem install \
docker-api \
rspec \
serverspec \
; \
gem list -q docker-api ; \
gem list -q rspec ; \
gem list -q serverspec ; \
rspec --version ; \
rm -rf /root/.cache /root/.gem ; \
fi

ENTRYPOINT ["/sbin/tini", "--", "/docker-entrypoint.sh"]

ENV DOCKER_COMMAND="bash"
CMD ["bash"]
ENV DOCKER_COMMAND="/bin/bash"
CMD ["${DOCKER_COMMAND}"]
71 changes: 34 additions & 37 deletions Dockerfile.centos
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,57 @@ ARG RUNIT_VERSION
ARG SU_EXEC_VERSION
ARG TINI_VERSION

RUN set -ex \
RUN set -exo pipefail ; \
# Update system
&& yum update -y \
yum update -y ; \
# Install packages
&& yum install -y \
yum install -y \
less \
openssl \
; \
# Install jq
&& curl -fL -o /usr/bin/jq https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 \
&& chmod +x /usr//bin/jq \
curl -fL -o /usr/bin/jq https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 ; \
chmod +x /usr//bin/jq ; \
# Install tini
&& curl -fL -o /sbin/tini https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini \
&& chmod +x /sbin/tini \
curl -fL -o /sbin/tini https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini ; \
chmod +x /sbin/tini ; \
# Install development dependencies
&& yum history new \
|| yum history new \
&& yum install -y \
yum history new || yum history new ; \
yum install -y \
gcc \
glibc-static \
make \
; \
# Install runit
&& mkdir /package \
&& cd /package \
&& curl http://smarden.org/runit/runit-${RUNIT_VERSION}.tar.gz | tar xzf - \
&& cd admin/runit-${RUNIT_VERSION} \
&& package/compile \
&& package/check \
&& mv command/* /sbin \
&& mkdir -p /etc/service \
&& cd / \
&& rm -rf /package \
mkdir /package ; \
cd /package ; \
curl http://smarden.org/runit/runit-${RUNIT_VERSION}.tar.gz | tar xzf - ; \
cd admin/runit-${RUNIT_VERSION} ; \
package/compile ; \
package/check ; \
mv command/* /sbin ; \
mkdir -p /etc/service ; \
cd / ; \
rm -rf /package ; \
# Install su-exec
&& cd /tmp \
&& curl -fL https://github.com/ncopa/su-exec/archive/v${SU_EXEC_VERSION}.tar.gz | tar xfz - \
&& cd su-exec-${SU_EXEC_VERSION} \
&& make \
&& mv su-exec /sbin \
&& cd .. \
&& rm -rf su-exec-${SU_EXEC_VERSION} \
&& cd / \
curl -fL https://github.com/ncopa/su-exec/archive/v${SU_EXEC_VERSION}.tar.gz \
| tar xfz - -C /tmp ; \
cd /tmp/su-exec-${SU_EXEC_VERSION} ; \
make ; \
mv su-exec /sbin ; \
cd .. ; \
rm -rf su-exec-${SU_EXEC_VERSION} ; \
cd / ; \
# Uninstall development dependencies
&& yum history -y undo 1 \
yum history -y undo 1 ; \
# Cleanup yum
&& yum clean all \
;
yum clean all

COPY config /
RUN set -ex \
&& chmod +x /docker-entrypoint.sh \
# Check custom bash config files
&& bash -i -l -c "true" \
;
RUN set -exo pipefail ; \
chmod +x /docker-entrypoint.sh

ENTRYPOINT ["/sbin/tini", "--", "/docker-entrypoint.sh"]

ENV DOCKER_COMMAND="/bin/bash"
CMD ["/bin/bash"]
CMD ["${DOCKER_COMMAND}"]
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ BASEIMAGE_TAG ?= 3.6
################################################################################

DOCKER_PROJECT ?= sicz
DOCKER_NAME = baseimage-$(BASEIMAGE_NAME)
DOCKER_NAME ?= baseimage-$(BASEIMAGE_NAME)
DOCKER_TAG ?= $(BASEIMAGE_TAG)
DOCKER_TAGS ?= latest
DOCKER_DESCRIPTION = $(BASEIMAGE_OS_NAME) based image modified for Docker-friendliness
DOCKER_PROJECT_URL = $(BASEIMAGE_OS_URL)
DOCKER_DESCRIPTION ?= $(BASEIMAGE_OS_NAME) based image modified for Docker-friendliness
DOCKER_PROJECT_URL ?= $(BASEIMAGE_OS_URL)

DOCKER_RUN_OPTS += -v /var/run/docker.sock:/var/run/docker.sock \
$(DOCKER_SHELL_OPTS)
Expand All @@ -22,7 +22,7 @@ DOCKER_RUN_OPTS += -v /var/run/docker.sock:/var/run/docker.sock \

DOCKER_FILE = Dockerfile.$(BASEIMAGE_NAME)

DOCKER_SUBDIRS = devel centos centos/devel
DOCKER_SUBDIRS = devel dockerspec dockerspec/devel centos centos/devel

################################################################################

Expand All @@ -45,6 +45,7 @@ logs-tail: docker-logs-tail
shell: docker-shell
test: destroy # deploy-simple-ca
@DOCKER_RUN_OPTS="$(DOCKER_RUN_OPTS)"; \
touch $(DOCKER_HOME_DIR)/secrets/ca_crt.pem $(DOCKER_HOME_DIR)/secrets/ca_user.pwd; \
DOCKER_RUN_OPTS="$${DOCKER_RUN_OPTS} -v $(abspath $(DOCKER_HOME_DIR))/secrets/ca_crt.pem:/run/secrets/ca_crt.pem"; \
DOCKER_RUN_OPTS="$${DOCKER_RUN_OPTS} -v $(abspath $(DOCKER_HOME_DIR))/secrets/ca_user.pwd:/run/secrets/ca_user.pwd"; \
$(MAKE) start DOCKER_RUN_OPTS="$${DOCKER_RUN_OPTS}"; \
Expand All @@ -69,6 +70,8 @@ clean-secrets:
fi; \
fi

# TODO: copy ca_crt.pem and ca_user.pwd from simple_ca into container
# because on CircleCI we cannot use host volumes
deploy-simple-ca: destroy-simple-ca
@$(ECHO) -n "Deploying container: "; \
DOCKER_SIMPLE_CA_ID="$(DOCKER_CONTAINER_NAME)_simple_ca"; \
Expand Down
5 changes: 3 additions & 2 deletions config/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fi

################################################################################

info "Executing command: $@"
exec "$@"
debug "Raw command: $@"
eval info "Executing command: $@"
eval exec "$@"

################################################################################
25 changes: 25 additions & 0 deletions dockerspec/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
################################################################################

DOCKER_NAME = dockerspec
DOCKER_DESCRIPTION = An image intended to run Docker image tests using RSpec and ServerSpec
DOCKER_PROJECT_URL = http://serverspec.org

DOCKER_BUILD_VARS += DOCKER_VERSION

DOCKER_RUN_OPTS += -v $(abspath $(DOCKER_HOME_DIR))/.rspec:/.rspec \
-v $(abspath $(DOCKER_HOME_DIR))/spec:/spec

################################################################################

# Docker Compose file version:
# - docker: 3.3
# - docker-compose: 3.3
DOCKER_VERSION ?= 17.06.0-ce
DOCKER_COMPOSE_VERSION ?= 1.15.0

################################################################################

DOCKER_HOME_DIR ?= ..
include $(DOCKER_HOME_DIR)/Makefile

################################################################################
Loading

0 comments on commit ee946cd

Please sign in to comment.