Skip to content

Commit eb840a1

Browse files
committed
User Docker Build action in CI
1 parent 0d3cf39 commit eb840a1

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,30 @@ 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
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: Build & Test Client
59+
if: (github.event_name != 'schedule')
60+
run: make test
5461
- name: Build & Test Client (Nightly)
5562
if: (github.event_name == 'schedule')
5663
run: make test

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 \

0 commit comments

Comments
 (0)