Skip to content

Commit f1790e6

Browse files
authored
Bootstrap the repository (#1)
1 parent b88fb0c commit f1790e6

8 files changed

Lines changed: 197 additions & 0 deletions

File tree

.github/main.workflow

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
workflow "Lint all Dockerfiles" {
2+
on = "push"
3+
resolves = ["Haskell Dockerfile Linter"]
4+
}
5+
6+
action "Haskell Dockerfile Linter" {
7+
uses = "docker://cdssnc/docker-lint-github-action"
8+
# https://github.com/hadolint/hadolint/wiki/DL3008
9+
# https://github.com/hadolint/hadolint/wiki/DL3013
10+
# https://github.com/hadolint/hadolint/wiki/DL3016
11+
# https://github.com/hadolint/hadolint/wiki/DL3018
12+
args = "--ignore DL3008 --ignore DL3013 --ignore DL3016 --ignore DL3018"
13+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
.vscode
3+
*.DS_Store
4+
test-project

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
branches:
2+
only:
3+
- master
4+
- /^it\/.*$/
5+
language: minimal
6+
services:
7+
- docker
8+
script: chmod +x runTests.sh && ./runTests.sh

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Guidance on how to contribute
2+
3+
There are two primary ways to help:
4+
* using the issue tracker, and
5+
* changing the code-base.
6+
7+
## Using the issue tracker
8+
9+
Use the issue tracker to suggest feature requests, report bugs, and ask
10+
questions. This is also a great way to connect with the developers of the
11+
project as well as others who are interested in this solution.
12+
13+
Use the issue tracker to find ways to contribute. Find a bug or a feature,
14+
mention in the issue that you will take on that effort, then follow the
15+
guidance below.
16+
17+
## Changing the code-base
18+
19+
Generally speaking, you should fork this repository, make changes in your own
20+
fork, and then submit a pull-request. All new code should have been thoroughly
21+
tested end-to-end in order to validate implemented features and the presence or
22+
lack of defects. All new scripts and docker files _must_ come with automated (unit)
23+
tests.
24+
25+
The contract of functionality exposed by docker files functionality needs
26+
to be documented, so it can be properly used. Implementation of a functionality
27+
and its documentation shall happen within the same commit(s).
28+
29+
#### Consistent USER Instruction in the Dockerfile
30+
31+
Set the user name (or UID) and the user group (or GID) to UID 1000 and GID 1000 to be consistent ith the Jenkins image.
32+
33+
````
34+
USER 1000:1000
35+
````

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM buildpack-deps:stretch-curl
2+
3+
ENV VERSION 0.1
4+
5+
# https://github.com/hadolint/hadolint/wiki/DL4006
6+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
7+
8+
# ps needs to be available to be able to be used in docker.inside, see https://issues.jenkins-ci.org/browse/JENKINS-40101
9+
RUN apt-get update && \
10+
apt-get install -y --no-install-recommends procps && \
11+
rm -rf /var/lib/apt/lists/*
12+
13+
# add group & user
14+
RUN addgroup -gid 1000 piper && \
15+
useradd piper --uid 1000 --gid 1000 --shell /bin/bash --create-home && \
16+
curl --location --silent "https://cli.run.pivotal.io/stable?release=linux64-binary&source=github" | tar -zx -C /usr/local/bin && \
17+
cf --version
18+
19+
USER piper
20+
WORKDIR /home/piper
21+
22+
ARG MTA_PLUGIN_VERSION=2.1.0
23+
ARG MTA_PLUGIN_URL=https://github.com/cloudfoundry-incubator/multiapps-cli-plugin/releases/download/v${MTA_PLUGIN_VERSION}/mta_plugin_linux_amd64
24+
25+
RUN cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org && \
26+
cf install-plugin blue-green-deploy -f -r CF-Community && \
27+
cf install-plugin ${MTA_PLUGIN_URL} -f && \
28+
cf plugins

NOTICE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved.
2+

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
## CloudFoundry CLI Image
2+
3+
The CX Server is a collection of [_Dockerfiles_](https://docs.docker.com/engine/reference/builder/) for images that can be used in _Continuous Delivery_ (CD) pipelines for SAP development projects.
4+
The images are optimized for use with project ["Piper"](https://github.com/SAP/jenkins-library) on [Jenkins](https://jenkins.io/).
5+
Docker containers simplify your CD tool setup, encapsulating tools and environments that are required to execute pipeline steps.
6+
7+
If you want to learn how to use project "Piper" please have a look at [the documentation](https://github.com/SAP/jenkins-library/blob/master/README.md).
8+
Introductory material and a lot of SAP scenarios not covered by project "Piper" are described in our [Continuous Integration Best Practices](https://developers.sap.com/tutorials/ci-best-practices-intro.html).
9+
10+
This repository contains Dockerfiles that are designed to run project "Piper" pipelines.
11+
Nevertheless, they can also be used flexibly in any custom environment and automation process.
12+
13+
## About this repository
14+
15+
Dockerfile for an image with the CloudFoundry CLI and plugins for blue-green deployment and MTA.
16+
This image is intended to be used in Jenkins pipelines.
17+
18+
## Download
19+
20+
This image is published to Docker Hub and can be pulled via the command
21+
22+
```
23+
docker pull ppiper/cf-cli
24+
```
25+
26+
## Build
27+
28+
To build this image locally, open a terminal in the directory of the Dockerfile an run
29+
30+
```
31+
docker build -t ppiper/cf-cli .
32+
```
33+
34+
## Usage
35+
36+
Recommended usage of this image is via [`cloudFoundryDeploy`](https://sap.github.io/jenkins-library/steps/cloudFoundryDeploy/) pipeline step.
37+
38+
For using the `cf` tool via this image, it can be invoked like in this command
39+
40+
```
41+
docker run ppiper/cf-cli cf
42+
```
43+
44+
## Testing
45+
46+
### Running as a Service
47+
48+
See `.travis.yml` file for configuration.
49+
50+
Configure the following variables (secrets)
51+
52+
* `CX_INFRA_IT_CF_USERNAME` (user name for deployment to SAP Cloud Platform)
53+
* `CX_INFRA_IT_CF_PASSWORD` (password for deployment to SAP Cloud Platform)
54+
55+
### Running locally
56+
57+
Docker is required, and at least 4 GB of memory assigned to Docker.
58+
59+
```bash
60+
export CX_INFRA_IT_CF_USERNAME="myusername"
61+
export CX_INFRA_IT_CF_PASSWORD="mypassword"
62+
./runTests.sh
63+
```
64+
65+
## License
66+
67+
Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved.
68+
This file is licensed under the Apache Software License, v. 2 except as noted
69+
otherwise in the [LICENSE file](https://github.com/SAP/devops-docker-images/blob/master/LICENSE).
70+
71+
Please note that Docker images can contain other software which may be licensed under different licenses. This License file is also included in the Docker image. For any usage of built Docker images please make sure to check the licenses of the artifacts contained in the images.

runTests.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash -e
2+
3+
# Sanity check
4+
if [ -z "$CX_INFRA_IT_CF_USERNAME" ]; then
5+
echo "Failure: Variable CX_INFRA_IT_CF_USERNAME is unset"
6+
exit 1
7+
fi
8+
9+
if [ -z "$CX_INFRA_IT_CF_PASSWORD" ]; then
10+
echo "Failure: Variable CX_INFRA_IT_CF_PASSWORD is unset"
11+
exit 1
12+
fi
13+
14+
set -x
15+
16+
# Start a local registry, to which we push the images built in this test, and from which they will be consumed in the test
17+
docker run -d -p 5000:5000 --restart always --name registry registry:2 || true
18+
19+
docker build -t localhost:5000/ppiper/cf-cli:latest .
20+
docker tag localhost:5000/ppiper/cf-cli:latest ppiper/cf-cli:latest
21+
docker push localhost:5000/ppiper/cf-cli:latest
22+
23+
git clone https://github.com/piper-validation/cloud-s4-sdk-book.git -b validate-cf-cli test-project
24+
pushd test-project
25+
26+
docker run -v //var/run/docker.sock:/var/run/docker.sock -v $(pwd):/workspace -v /tmp \
27+
-e CX_INFRA_IT_CF_PASSWORD -e CX_INFRA_IT_CF_USERNAME -e BRANCH_NAME=master \
28+
-e CASC_JENKINS_CONFIG=/workspace/jenkins.yml -e HOST=$(hostname) \
29+
ppiper/jenkinsfile-runner
30+
31+
popd
32+
33+
function cleanup {
34+
rm -rf test-project
35+
}
36+
trap cleanup EXIT

0 commit comments

Comments
 (0)