Skip to content

Commit

Permalink
Merge pull request #56 from slide/add_stretch_image
Browse files Browse the repository at this point in the history
Add image based on debian stretch and rework directory structure
  • Loading branch information
slide authored Apr 14, 2020
2 parents 04e6daf + c943e3a commit c8a81d4
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ bats-core/

/*/**/CreateProfile.psm1
/.vscode/
/*/**/setup-sshd
3 changes: 1 addition & 2 deletions 8/debian/Dockerfile → 11/debian/buster/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

FROM openjdk:8-jdk
LABEL MAINTAINER="Nicolas De Loof <[email protected]>"
FROM openjdk:11-jdk-buster

ARG user=jenkins
ARG group=jenkins
Expand Down
2 changes: 1 addition & 1 deletion 11/debian/Dockerfile → 11/debian/stretch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

FROM openjdk:11-jdk
FROM openjdk:11-jdk-stretch
LABEL MAINTAINER="Nicolas De Loof <[email protected]>"

ARG user=jenkins
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

FROM openjdk:11-jdk-windowsservercore-1809
FROM adoptopenjdk:11-jdk-hotspot-windowsservercore-1809

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

Expand Down
3 changes: 1 addition & 2 deletions 8/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

FROM openjdk:8-jdk-alpine
LABEL MAINTAINER="Fabio Kruger <[email protected]>"
FROM openjdk:8-jdk-alpine3.9

ARG user=jenkins
ARG group=jenkins
Expand Down
55 changes: 55 additions & 0 deletions 8/debian/buster/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# The MIT License
#
# Copyright (c) 2015, CloudBees, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

FROM openjdk:8-jdk-buster

ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000
ARG JENKINS_AGENT_HOME=/home/${user}

ENV JENKINS_AGENT_HOME ${JENKINS_AGENT_HOME}

RUN groupadd -g ${gid} ${group} \
&& useradd -d "${JENKINS_AGENT_HOME}" -u "${uid}" -g "${gid}" -m -s /bin/bash "${user}"

# setup SSH server
RUN apt-get update \
&& apt-get install --no-install-recommends -y openssh-server \
&& rm -rf /var/lib/apt/lists/*
RUN sed -i /etc/ssh/sshd_config \
-e 's/#PermitRootLogin.*/PermitRootLogin no/' \
-e 's/#RSAAuthentication.*/RSAAuthentication yes/' \
-e 's/#PasswordAuthentication.*/PasswordAuthentication no/' \
-e 's/#SyslogFacility.*/SyslogFacility AUTH/' \
-e 's/#LogLevel.*/LogLevel INFO/' && \
mkdir /var/run/sshd

VOLUME "${JENKINS_AGENT_HOME}" "/tmp" "/run" "/var/run"
WORKDIR "${JENKINS_AGENT_HOME}"

COPY setup-sshd /usr/local/bin/setup-sshd

EXPOSE 22

ENTRYPOINT ["setup-sshd"]
55 changes: 55 additions & 0 deletions 8/debian/stretch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# The MIT License
#
# Copyright (c) 2015, CloudBees, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

FROM openjdk:8-jdk-stretch

ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000
ARG JENKINS_AGENT_HOME=/home/${user}

ENV JENKINS_AGENT_HOME ${JENKINS_AGENT_HOME}

RUN groupadd -g ${gid} ${group} \
&& useradd -d "${JENKINS_AGENT_HOME}" -u "${uid}" -g "${gid}" -m -s /bin/bash "${user}"

# setup SSH server
RUN apt-get update \
&& apt-get install --no-install-recommends -y openssh-server \
&& rm -rf /var/lib/apt/lists/*
RUN sed -i /etc/ssh/sshd_config \
-e 's/#PermitRootLogin.*/PermitRootLogin no/' \
-e 's/#RSAAuthentication.*/RSAAuthentication yes/' \
-e 's/#PasswordAuthentication.*/PasswordAuthentication no/' \
-e 's/#SyslogFacility.*/SyslogFacility AUTH/' \
-e 's/#LogLevel.*/LogLevel INFO/' && \
mkdir /var/run/sshd

VOLUME "${JENKINS_AGENT_HOME}" "/tmp" "/run" "/var/run"
WORKDIR "${JENKINS_AGENT_HOME}"

COPY setup-sshd /usr/local/bin/setup-sshd

EXPOSE 22

ENTRYPOINT ["setup-sshd"]
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ ARG JENKINS_AGENT_WORK="C:/Users/${user}/Work"
ENV JENKINS_AGENT_USER ${user}
ENV JENKINS_AGENT_WORK ${JENKINS_AGENT_WORK}

USER ContainerAdministrator

# setup SSH server
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
$url = 'https://github.com/PowerShell/Win32-OpenSSH/releases/download/{0}/OpenSSH-Win64.zip' -f $env:OPENSSH_VERSION ; `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

FROM openjdk:8-jdk-windowsservercore-1809
FROM adoptopenjdk:8-jdk-hotspot-windowsservercore-1809

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

Expand Down
41 changes: 29 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,53 @@ ROOT:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

IMAGE_NAME:=jenkins4eval/ssh-slave
IMAGE_ALPINE:=${IMAGE_NAME}:alpine
IMAGE_DEBIAN:=${IMAGE_NAME}:test
IMAGE_BUSTER:=${IMAGE_NAME}:test
IMAGE_STRETCH=${IMAGE_NAME}:stretch
IMAGE_JDK11:=${IMAGE_NAME}:jdk11
IMAGE_STRETCH_JDK11=${IMAGE_NAME}:jdk11-stretch

build: build-alpine build-debian build-jdk11
build: build-alpine build-buster build-stretch build-jdk11 build-stretch-jdk11

build-alpine:
cp -f setup-sshd 8/alpine/
docker build -t ${IMAGE_ALPINE} 8/alpine

build-debian:
cp -f setup-sshd 8/debian/
docker build -t ${IMAGE_DEBIAN} 8/debian
build-buster:
cp -f setup-sshd 8/debian/buster/
docker build -t ${IMAGE_BUSTER} 8/debian/buster

build-stretch:
cp -f setup-sshd 8/debian/stretch/
docker build -t ${IMAGE_STRETCH} 8/debian/stretch

build-jdk11:
cp -f setup-sshd 11/debian/
docker build -t ${IMAGE_JDK11} 11/debian
cp -f setup-sshd 11/debian/buster/
docker build -t ${IMAGE_JDK11} 11/debian/buster

build-stretch-jdk11:
cp -f setup-sshd 11/debian/stretch/
docker build -t ${IMAGE_STRETCH_JDK11} 11/debian/stretch


bats:
# The lastest version is v1.1.0
@if [ ! -d bats-core ]; then git clone https://github.com/bats-core/bats-core.git; fi
@git -C bats-core reset --hard c706d1470dd1376687776bbe985ac22d09780327

.PHONY: test test-alpine test-jdk11 test-debian
test: bats test-alpine test-jdk11 test-debian
.PHONY: test test-alpine test-jdk11 test-buster test-stretch test-stretch-jdk11
test: bats test-alpine test-jdk11 test-buster test-stretch test-stretch-jdk11

test-alpine:
@FOLDER="8/alpine" bats-core/bin/bats tests/tests.bats

test-jdk11:
@FOLDER="11/debian" bats-core/bin/bats tests/tests.bats
@FOLDER="11/debian/buster" bats-core/bin/bats tests/tests.bats

test-buster:
@FOLDER="8/debian/buster" bats-core/bin/bats tests/tests.bats

test-stretch:
@FOLDER="8/debian/stretch" bats-core/bin/bats tests/tests.bats

test-debian:
@FOLDER="8/debian" bats-core/bin/bats tests/tests.bats
test-stretch-jdk11:
@FOLDER="11/debian/stretch" bats-core/bin/bats tests/tests.bats
8 changes: 4 additions & 4 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ if(![String]::IsNullOrWhiteSpace($env:DOCKERHUB_ORGANISATION)) {

$builds = @{
'jdk8' = @{
'Folder' = '8\windowsservercore-1809';
'Folder' = '8\windows\windowsservercore-1809';
'Tags' = @( "windowsservercore-1809", "windowsservercore-1809-jdk8" );
};
'jdk11' = @{
'Folder' = '11\windowsservercore-1809';
'Folder' = '11\windows\windowsservercore-1809';
'Tags' = @( "windowsservercore-1809-jdk11" );
};
'nanoserver' = @{
'Folder' = '8\nanoserver-1809';
'Folder' = '8\windows\nanoserver-1809';
'Tags' = @( "nanoserver-1809", "nanoserver-1809-jdk8" );
};
'nanoserver-jdk11' = @{
'Folder' = '11\nanoserver-1809';
'Folder' = '11\windows\nanoserver-1809';
'Tags' = @( "nanoserver-1809-jdk11" );
};
}
Expand Down

0 comments on commit c8a81d4

Please sign in to comment.