Skip to content

Commit 865274b

Browse files
authored
User Docker Build action in CI (#78)
1 parent 0d3cf39 commit 865274b

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,31 @@ jobs:
3434
steps:
3535
- name: Checkout Repository
3636
uses: actions/checkout@v2
37-
- name: Fetch Certificates
38-
env:
39-
CRT: ${{ secrets.NGINX_CRT }}
40-
KEY: ${{ secrets.NGINX_KEY }}
41-
run: |
42-
echo "${CRT}" | base64 --decode > docker/nginx-repo.crt
43-
echo "${KEY}" | base64 --decode > docker/nginx-repo.key
44-
- name: Build & Test Client
45-
if: (github.event_name != 'schedule')
46-
run: make test
37+
- name: Determine NGINX Plus version
38+
run: echo "NGINX_PLUS_VERSION=$(cat Makefile | grep -m1 NGINX_PLUS_VERSION | cut -d "=" -f2)" >> $GITHUB_ENV
4739
- name: Switch Repository (Nightly)
4840
if: (github.event_name == 'schedule')
4941
run: |
5042
sed -i 's|pkgs.nginx.com|pkgs-test.nginx.com|g' docker/Dockerfile
5143
sed -i '15d' docker/Dockerfile
5244
sed -i 's|deb https|deb [trusted=yes] https|g' docker/Dockerfile
53-
sed -i 's|nginx-plus-\${NGINX_PLUS_VERSION}|nginx-plus|g' docker/Dockerfile
54-
- name: Build & Test Client (Nightly)
45+
sed -i 's|nginx-plus-\${{ env.NGINX_PLUS_VERSION }}|nginx-plus|g' docker/Dockerfile
46+
- name: Build Plus Docker Image
47+
uses: docker/build-push-action@v2
48+
with:
49+
file: docker/Dockerfile
50+
context: 'docker'
51+
tags: nginx-plus:${{ env.NGINX_PLUS_VERSION }}
52+
load: true
53+
secrets: |
54+
"nginx-repo.crt=${{ secrets.NGINX_CRT }}"
55+
"nginx-repo.key=${{ secrets.NGINX_KEY }}"
56+
build-args:
57+
NGINX_PLUS_VERSION=${{ env.NGINX_PLUS_VERSION }}
58+
- name: Test Client
59+
if: (github.event_name != 'schedule')
60+
run: make test
61+
- name: Test Client (Nightly)
5562
if: (github.event_name == 'schedule')
5663
run: make test
5764
env:

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
NGINX_PLUS_VERSION=r24
2-
NGINX_IMAGE=nginxplus:$(NGINX_PLUS_VERSION)
32
DOCKER_NETWORK?=test
43
DOCKER_NETWORK_ALIAS=nginx-plus-test
54
DOCKER_NGINX_PLUS?=nginx-plus
@@ -11,18 +10,18 @@ export TEST_API_ENDPOINT=http://$(DOCKER_NGINX_PLUS):8080/api
1110
export TEST_API_ENDPOINT_OF_HELPER=http://$(DOCKER_NGINX_PLUS_HELPER):8080/api
1211
export TEST_UNAVAILABLE_STREAM_ADDRESS=$(DOCKER_NGINX_PLUS):8081
1312

14-
test: docker-build run-nginx-plus test-run configure-no-stream-block test-run-no-stream-block clean
13+
test: run-nginx-plus test-run configure-no-stream-block test-run-no-stream-block clean
1514

1615
lint:
1716
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
1817

1918
docker-build:
20-
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
19+
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
2120

2221
run-nginx-plus:
2322
docker network create --driver bridge $(DOCKER_NETWORK)
24-
docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS) --network-alias=$(DOCKER_NETWORK_ALIAS) --rm -p 8080:8080 -p 8081:8081 $(NGINX_IMAGE)
25-
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)
23+
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)
24+
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)
2625

2726
test-run:
2827
docker run --rm \

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This Client works against version 5 of NGINX Plus API. Version 5 was introduced
1616
## Using the Client
1717

1818
1. Import `github.com/nginxinc/nginx-plus-go-client/client` into your go project.
19-
2. Use your favourite vendor tool to add this to your `/vendor` directory in your project.
19+
2. Use your favorite vendor tool to add this to your `/vendor` directory in your project.
2020

2121
## Testing
2222

@@ -37,7 +37,7 @@ Prerequisites:
3737
Run Tests:
3838

3939
```
40-
$ make test
40+
$ make docker-build && make test
4141
```
4242

4343
This will build and run two NGINX Plus containers and create one docker network of type bridge, execute the client tests against both NGINX Plus APIs, and then clean up. If it fails and you want to clean up (i.e. stop the running containers and remove the docker network), please use `$ make clean`

0 commit comments

Comments
 (0)