-
Notifications
You must be signed in to change notification settings - Fork 823
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #738 from buchdag/github-actions
Migrate CI to GitHub Actions as Travis CI is ending their free OSS builds
- Loading branch information
Showing
25 changed files
with
349 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '*.md' | ||
pull_request: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '*.md' | ||
|
||
|
||
env: | ||
DOCKER_GEN_CONTAINER_NAME: nginx-proxy-gen | ||
IMAGE: jrcs/letsencrypt-nginx-proxy-companion | ||
NGINX_CONTAINER_NAME: nginx-proxy | ||
TEST_DOMAINS: le1.wtf,le2.wtf,le3.wtf | ||
|
||
jobs: | ||
companion-build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
- name: Patch the Dockerfile's docker-gen | ||
run: | | ||
sed -i 's#DOCKER_GEN_VERSION=.*$#DOCKER_GEN_VERSION=fix-current-container-id#g' Dockerfile | ||
sed -i 's#go get github.com/jwilder/docker-gen#go get github.com/buchdag/docker-gen \&\& mv /go/src/github.com/buchdag /go/src/github.com/jwilder#g' Dockerfile | ||
- name: Build Image | ||
run: docker build -t "$IMAGE" . | ||
- name: Inspect Image | ||
run: docker inspect "$IMAGE" | ||
- name: Get acme.sh Version | ||
run: docker run --rm "$IMAGE" acme.sh --version | ||
- name: List Docker Images | ||
run: docker images | ||
- name: Export Image Artifact | ||
run: docker save $IMAGE > companion.tar | ||
- name: Upload Image Artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: companion.tar | ||
path: companion.tar | ||
|
||
nginx-proxy-build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
- name: Build patched nginx-proxy Image | ||
run: docker build -t "jwilder/nginx-proxy:latest" ./test/setup/nginx-proxy | ||
- name: Build patched docker-gen Image | ||
run: docker build -t "jwilder/docker-gen:latest" ./test/setup/docker-gen | ||
- name: List Docker Images | ||
run: docker images | ||
- name: Export Images Artifacts | ||
run: | | ||
docker save jwilder/nginx-proxy:latest > nginx-proxy.tar | ||
docker save jwilder/docker-gen:latest > docker-gen.tar | ||
- name: Upload nginx-proxy Image Artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: nginx-proxy.tar | ||
path: nginx-proxy.tar | ||
- name: Upload docker-gen Image Artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: docker-gen.tar | ||
path: docker-gen.tar | ||
|
||
docker-specs-testing: | ||
needs: companion-build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: docker-library/official-images | ||
path: official-images | ||
- name: Download Builded Image | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: companion.tar | ||
- name: Import Builded Image | ||
run: docker load < companion.tar | ||
- name: Docker Specifications Testing | ||
run: official-images/test/run.sh "$IMAGE" | ||
- if: ${{ failure() }} | ||
run: test/github_actions/containers-logs.sh | ||
|
||
integration-testing: | ||
needs: | ||
- companion-build | ||
- nginx-proxy-build | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
setup: [2containers, 3containers] | ||
test-name: | ||
[ | ||
docker_api, | ||
location_config, | ||
default_cert, | ||
certs_single, | ||
certs_san, | ||
certs_single_domain, | ||
certs_standalone, | ||
force_renew, | ||
acme_accounts, | ||
private_keys, | ||
container_restart, | ||
permissions_default, | ||
permissions_custom, | ||
symlinks, | ||
] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
# PREPARE RUNNER ENV | ||
- name: Add Test Domains in /etc/hosts | ||
run: | | ||
test_domains=$(echo $TEST_DOMAINS | tr "," "\n") | ||
for domain in $test_domains | ||
do | ||
echo "127.0.0.1 $domain" | sudo tee -a /etc/hosts | ||
done | ||
- name: Setup Boulder | ||
run: test/setup/setup-boulder.sh | ||
- name: Download nginx-proxy Patched Image | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: nginx-proxy.tar | ||
- name: Download docker-gen Patched Image | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: docker-gen.tar | ||
- name: Import nginx-proxy patched Images | ||
run: | | ||
docker load < nginx-proxy.tar | ||
docker load < docker-gen.tar | ||
- name: Setup NGINX Proxy | ||
env: | ||
SETUP: ${{ matrix.setup }} | ||
run: test/setup/setup-nginx-proxy.sh | ||
# ADD BUILDED IMAGE | ||
- name: Download Builded Image | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: companion.tar | ||
- name: Import Builded Image | ||
run: docker load < companion.tar | ||
# TEST | ||
- name: Integration Testing | ||
env: | ||
SETUP: ${{ matrix.setup }} | ||
run: test/run.sh -t ${{ matrix.test-name }} "$IMAGE" | ||
- if: ${{ failure() }} | ||
run: test/github_actions/containers-logs.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
bold_echo() { | ||
echo -e "\033[33;1m$1\033[0m" | ||
} | ||
|
||
if [[ -f "$GITHUB_WORKSPACE/test/github_actions/failed_tests.txt" ]]; then | ||
mapfile -t containers < "$GITHUB_WORKSPACE/test/github_actions/failed_tests.txt" | ||
fi | ||
|
||
containers+=("$NGINX_CONTAINER_NAME") | ||
[[ $SETUP = "3containers" ]] && containers+=("$DOCKER_GEN_CONTAINER_NAME") | ||
containers+=("boulder") | ||
|
||
for container in "${containers[@]}"; do | ||
bold_echo "Docker container output for $container" | ||
docker logs "$container" | ||
docker inspect "$container" | ||
if [[ "$container" == "acme_accounts" ]]; then | ||
bold_echo "Docker container output for ${container}_default" | ||
docker logs "${container}_default" | ||
docker inspect "${container}_default" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM golang:1.15-alpine AS build-docker-gen | ||
|
||
ARG DOCKER_GEN_VERSION=fix-current-container-id | ||
|
||
LABEL stage=intermediate | ||
|
||
# Install build dependencies for docker-gen | ||
RUN apk add --update \ | ||
curl \ | ||
gcc \ | ||
git \ | ||
make \ | ||
musl-dev | ||
|
||
# Build docker-gen | ||
RUN go get github.com/buchdag/docker-gen \ | ||
&& mv /go/src/github.com/buchdag /go/src/github.com/jwilder \ | ||
&& cd /go/src/github.com/jwilder/docker-gen \ | ||
&& git -c advice.detachedHead=false checkout $DOCKER_GEN_VERSION \ | ||
&& make get-deps \ | ||
&& make all | ||
|
||
FROM alpine:3.8 | ||
|
||
LABEL maintainer="Nicolas Duchon <[email protected]>" | ||
|
||
# DOCKER_GEN_VERSION environment variable is required by letsencrypt-nginx-proxy-companion | ||
ENV DOCKER_GEN_VERSION=0.7.4 \ | ||
DOCKER_HOST=unix:///tmp/docker.sock | ||
|
||
# Copy docker-gen binary from build stage | ||
COPY --from=build-docker-gen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/ | ||
|
||
# Get latest nginx.tmpl | ||
ADD https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl /etc/docker-gen/templates/ | ||
|
||
ENTRYPOINT ["/usr/local/bin/docker-gen"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
FROM golang:1.15-alpine AS go-builder | ||
|
||
ARG DOCKER_GEN_VERSION=fix-current-container-id | ||
ARG FOREGO_VERSION=20180216151118 | ||
|
||
LABEL stage=intermediate | ||
|
||
# Install build dependencies for docker-gen and forego | ||
RUN apk add --update \ | ||
curl \ | ||
gcc \ | ||
git \ | ||
make \ | ||
musl-dev | ||
|
||
# Build forego | ||
RUN go get github.com/ddollar/forego \ | ||
&& cd /go/src/github.com/ddollar/forego \ | ||
&& git -c advice.detachedHead=false checkout $FOREGO_VERSION \ | ||
&& make all | ||
|
||
# Build docker-gen | ||
RUN go get github.com/buchdag/docker-gen \ | ||
&& mv /go/src/github.com/buchdag /go/src/github.com/jwilder \ | ||
&& cd /go/src/github.com/jwilder/docker-gen \ | ||
&& git -c advice.detachedHead=false checkout $DOCKER_GEN_VERSION \ | ||
&& make get-deps \ | ||
&& make all | ||
|
||
FROM nginx:1.19-alpine | ||
|
||
LABEL maintainer="Nicolas Duchon <[email protected]>" | ||
|
||
# DOCKER_GEN_VERSION environment variable is required by letsencrypt-nginx-proxy-companion | ||
ENV DOCKER_GEN_VERSION=0.7.4 \ | ||
DOCKER_HOST=unix:///tmp/docker.sock | ||
|
||
# Install/update run dependencies | ||
RUN apk add --update \ | ||
bash \ | ||
ca-certificates \ | ||
curl \ | ||
openssl \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
# Configure Nginx and apply fix for very long server names | ||
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \ | ||
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf | ||
|
||
# Copy forego and docker-gen binaries from build stage | ||
COPY --from=go-builder /go/src/github.com/ddollar/forego/forego /usr/local/bin/ | ||
COPY --from=go-builder /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/ | ||
|
||
# Install nginx-proxy | ||
RUN mkdir /src /app \ | ||
&& curl -sSL https://github.com/jwilder/nginx-proxy/archive/master.tar.gz \ | ||
| tar -C /src -xz \ | ||
&& cp /src/nginx-proxy-master/Procfile /app/ \ | ||
&& cp /src/nginx-proxy-master/dhparam.pem.default /app/ \ | ||
&& cp /src/nginx-proxy-master/docker-entrypoint.sh /app/ \ | ||
&& cp /src/nginx-proxy-master/generate-dhparam.sh /app/ \ | ||
&& cp /src/nginx-proxy-master/nginx.tmpl /app/ \ | ||
&& cp /src/nginx-proxy-master/network_internal.conf /etc/nginx/ \ | ||
&& rm -rf /src | ||
|
||
WORKDIR /app | ||
|
||
VOLUME ["/etc/nginx/certs", "/etc/nginx/dhparam"] | ||
|
||
ENTRYPOINT ["/app/docker-entrypoint.sh"] | ||
CMD ["forego", "start", "-r"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.