Skip to content

Commit

Permalink
User Docker Build action in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Jul 13, 2021
1 parent 0d3cf39 commit eb840a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,30 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Fetch Certificates
env:
CRT: ${{ secrets.NGINX_CRT }}
KEY: ${{ secrets.NGINX_KEY }}
run: |
echo "${CRT}" | base64 --decode > docker/nginx-repo.crt
echo "${KEY}" | base64 --decode > docker/nginx-repo.key
- name: Build & Test Client
if: (github.event_name != 'schedule')
run: make test
- name: Determine NGINX Plus version
run: echo "NGINX_PLUS_VERSION=$(cat Makefile | grep -m1 NGINX_PLUS_VERSION | cut -d "=" -f2)" >> $GITHUB_ENV
- name: Switch Repository (Nightly)
if: (github.event_name == 'schedule')
run: |
sed -i 's|pkgs.nginx.com|pkgs-test.nginx.com|g' docker/Dockerfile
sed -i '15d' docker/Dockerfile
sed -i 's|deb https|deb [trusted=yes] https|g' docker/Dockerfile
sed -i 's|nginx-plus-\${NGINX_PLUS_VERSION}|nginx-plus|g' docker/Dockerfile
sed -i 's|nginx-plus-\${{ env.NGINX_PLUS_VERSION }}|nginx-plus|g' docker/Dockerfile
- name: Build Plus Docker Image
uses: docker/build-push-action@v2
with:
file: docker/Dockerfile
context: 'docker'
tags: nginx-plus:${{ env.NGINX_PLUS_VERSION }}
load: true
secrets: |
"nginx-repo.crt=${{ secrets.NGINX_CRT }}"
"nginx-repo.key=${{ secrets.NGINX_KEY }}"
build-args:
NGINX_PLUS_VERSION=${{ env.NGINX_PLUS_VERSION }}
- name: Build & Test Client
if: (github.event_name != 'schedule')
run: make test
- name: Build & Test Client (Nightly)
if: (github.event_name == 'schedule')
run: make test
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
NGINX_PLUS_VERSION=r24
NGINX_IMAGE=nginxplus:$(NGINX_PLUS_VERSION)
DOCKER_NETWORK?=test
DOCKER_NETWORK_ALIAS=nginx-plus-test
DOCKER_NGINX_PLUS?=nginx-plus
Expand All @@ -11,18 +10,18 @@ export TEST_API_ENDPOINT=http://$(DOCKER_NGINX_PLUS):8080/api
export TEST_API_ENDPOINT_OF_HELPER=http://$(DOCKER_NGINX_PLUS_HELPER):8080/api
export TEST_UNAVAILABLE_STREAM_ADDRESS=$(DOCKER_NGINX_PLUS):8081

test: docker-build run-nginx-plus test-run configure-no-stream-block test-run-no-stream-block clean
test: run-nginx-plus test-run configure-no-stream-block test-run-no-stream-block clean

lint:
docker run --pull always --rm -v $(shell pwd):/nginx-plus-go-client -w /nginx-plus-go-client -v $(shell go env GOCACHE):/cache/go -e GOCACHE=/cache/go -e GOLANGCI_LINT_CACHE=/cache/go -v $(shell go env GOPATH)/pkg:/go/pkg golangci/golangci-lint:latest golangci-lint --color always run

docker-build:
docker build --secret id=nginx-repo.crt,src=docker/nginx-repo.crt --secret id=nginx-repo.key,src=docker/nginx-repo.key --build-arg NGINX_PLUS_VERSION=$(NGINX_PLUS_VERSION) -t $(NGINX_IMAGE) docker
docker build --secret id=nginx-repo.crt,src=docker/nginx-repo.crt --secret id=nginx-repo.key,src=docker/nginx-repo.key --build-arg NGINX_PLUS_VERSION=$(NGINX_PLUS_VERSION) -t nginx-plus:$(NGINX_PLUS_VERSION) docker

run-nginx-plus:
docker network create --driver bridge $(DOCKER_NETWORK)
docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS) --network-alias=$(DOCKER_NETWORK_ALIAS) --rm -p 8080:8080 -p 8081:8081 $(NGINX_IMAGE)
docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS_HELPER) --network-alias=$(DOCKER_NETWORK_ALIAS) --rm -p 8090:8080 -p 8091:8081 $(NGINX_IMAGE)
docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS) --network-alias=$(DOCKER_NETWORK_ALIAS) --rm -p 8080:8080 -p 8081:8081 nginx-plus:$(NGINX_PLUS_VERSION)
docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS_HELPER) --network-alias=$(DOCKER_NETWORK_ALIAS) --rm -p 8090:8080 -p 8091:8081 nginx-plus:$(NGINX_PLUS_VERSION)

test-run:
docker run --rm \
Expand Down

0 comments on commit eb840a1

Please sign in to comment.