-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
77 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
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 |
---|---|---|
@@ -1,53 +1,19 @@ | ||
NGINX_PLUS_VERSION=r30 | ||
DOCKER_NETWORK?=test | ||
DOCKER_NETWORK_ALIAS=nginx-plus-test | ||
DOCKER_NGINX_PLUS?=nginx-plus | ||
DOCKER_NGINX_PLUS_HELPER?=nginx-plus-helper | ||
|
||
GOLANG_CONTAINER=golang:1.19 | ||
|
||
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: run-nginx-plus test-run configure-no-stream-block test-run-no-stream-block clean | ||
test: test-all 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-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-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-all: | ||
docker compose up -d --build | ||
docker compose logs -f test-nginx test-client test-no-stream | ||
|
||
test-run: | ||
docker run --rm \ | ||
--network=$(DOCKER_NETWORK) \ | ||
-e TEST_API_ENDPOINT \ | ||
-e TEST_API_ENDPOINT_OF_HELPER \ | ||
-e TEST_UNAVAILABLE_STREAM_ADDRESS \ | ||
-v $(shell pwd):/go/src/github.com/nginxinc/nginx-plus-go-client \ | ||
-w /go/src/github.com/nginxinc/nginx-plus-go-client \ | ||
$(GOLANG_CONTAINER) /bin/sh -c "go test client/*; go clean -testcache; go test tests/client_test.go" | ||
|
||
configure-no-stream-block: | ||
docker cp docker/nginx_no_stream.conf $(DOCKER_NGINX_PLUS):/etc/nginx/nginx.conf | ||
docker exec $(DOCKER_NGINX_PLUS) nginx -s reload | ||
docker compose up -d --build test-nginx test-client | ||
docker compose logs -f test-nginx test-client | ||
|
||
test-run-no-stream-block: configure-no-stream-block | ||
docker run --rm \ | ||
--network=$(DOCKER_NETWORK) \ | ||
-e TEST_API_ENDPOINT \ | ||
-e TEST_API_ENDPOINT_OF_HELPER \ | ||
-e TEST_UNAVAILABLE_STREAM_ADDRESS \ | ||
-v $(shell pwd):/go/src/github.com/nginxinc/nginx-plus-go-client \ | ||
-w /go/src/github.com/nginxinc/nginx-plus-go-client \ | ||
$(GOLANG_CONTAINER) /bin/sh -c "go clean -testcache; go test tests/client_no_stream_test.go" | ||
test-run-no-stream-block: | ||
docker compose up -d --build test-no-stream | ||
docker compose logs -f test-no-stream | ||
|
||
clean: | ||
-docker kill $(DOCKER_NGINX_PLUS) | ||
-docker kill $(DOCKER_NGINX_PLUS_HELPER) | ||
-docker network rm $(DOCKER_NETWORK) | ||
docker compose down --remove-orphans |
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,70 @@ | ||
services: | ||
nginx: | ||
image: nginx-plus | ||
build: | ||
dockerfile: docker/Dockerfile | ||
secrets: | ||
- nginx-repo.crt | ||
- nginx-repo.key | ||
volumes: | ||
- type: bind | ||
source: ./docker/nginx.conf | ||
target: /etc/nginx/nginx.conf | ||
networks: | ||
default: | ||
aliases: | ||
- nginx-plus-test | ||
|
||
nginx-no-stream: | ||
extends: | ||
service: nginx | ||
volumes: | ||
- type: bind | ||
source: ./docker/nginx_no_stream.conf | ||
target: /etc/nginx/nginx.conf | ||
|
||
nginx-helper: | ||
extends: | ||
service: nginx | ||
|
||
test-nginx: | ||
image: golang:1.21 | ||
volumes: | ||
- type: bind | ||
source: ./ | ||
target: /go/src/github.com/nginxinc/nginx-plus-go-client | ||
working_dir: /go/src/github.com/nginxinc/nginx-plus-go-client | ||
command: /bin/sh -c "go test -v -shuffle=on -race client/*" | ||
depends_on: | ||
- nginx | ||
- nginx-helper | ||
environment: | ||
- TEST_API_ENDPOINT=http://nginx:8080/api | ||
- TEST_API_ENDPOINT_OF_HELPER=http://nginx-helper:8080/api | ||
- TEST_UNAVAILABLE_STREAM_ADDRESS=nginx:8081 | ||
|
||
test-client: | ||
extends: | ||
service: test-nginx | ||
depends_on: | ||
- nginx | ||
- nginx-helper | ||
command: go test -v -shuffle=on -race tests/client_test.go | ||
|
||
test-no-stream: | ||
extends: | ||
service: test-nginx | ||
command: go test -v -shuffle=on -race tests/client_no_stream_test.go | ||
depends_on: | ||
- nginx-no-stream | ||
- nginx-helper | ||
environment: | ||
- TEST_API_ENDPOINT=http://nginx-no-stream:8080/api | ||
- TEST_API_ENDPOINT_OF_HELPER=http://nginx-helper:8080/api | ||
- TEST_UNAVAILABLE_STREAM_ADDRESS=nginx-no-stream:8081 | ||
|
||
secrets: | ||
nginx-repo.crt: | ||
file: ./docker/nginx-repo.crt | ||
nginx-repo.key: | ||
file: ./docker/nginx-repo.key |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ FROM debian:bullseye-slim | |
|
||
LABEL maintainer="NGINX Docker Maintainers <[email protected]>" | ||
|
||
ARG NGINX_PLUS_VERSION | ||
ARG NGINX_PLUS_VERSION=R30 | ||
|
||
# Install NGINX Plus | ||
# Download certificate and key from the customer portal (https://my.f5.com) | ||
|
@@ -16,24 +16,19 @@ RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/ssl/nginx/nginx-repo.crt,mode | |
curl -fsSL https://cs.nginx.com/static/keys/nginx_signing.key | gpg --dearmor > /etc/apt/trusted.gpg.d/nginx_signing.gpg | ||
curl -fsSL -o /etc/apt/apt.conf.d/90pkgs-nginx https://cs.nginx.com/static/files/90pkgs-nginx | ||
DEBIAN_VERSION=$(awk -F '=' '/^VERSION_CODENAME=/ {print $2}' /etc/os-release) | ||
printf "%s\n" "deb https://pkgs.nginx.com/plus/${NGINX_PLUS_VERSION^^}/debian ${DEBIAN_VERSION} nginx-plus" > /etc/apt/sources.list.d/nginx-plus.list | ||
printf "%s\n" "deb https://pkgs.nginx.com/plus/${NGINX_PLUS_VERSION}/debian ${DEBIAN_VERSION} nginx-plus" > /etc/apt/sources.list.d/nginx-plus.list | ||
apt-get update | ||
apt-get install -y nginx-plus | ||
apt-get remove --purge --auto-remove -y gnupg | ||
rm -rf /var/lib/apt/lists/* | ||
rm /etc/apt/apt.conf.d/90pkgs-nginx /etc/apt/sources.list.d/nginx-plus.list | ||
eot | ||
|
||
# Forward request logs to Docker log collector | ||
RUN ln -sf /dev/stdout /var/log/nginx/access.log \ | ||
&& ln -sf /dev/stderr /var/log/nginx/error.log | ||
|
||
EXPOSE 80 | ||
EXPOSE 8080 8081 | ||
|
||
STOPSIGNAL SIGQUIT | ||
|
||
RUN rm -rf /etc/nginx/conf.d/* | ||
COPY --link test.conf /etc/nginx/conf.d/ | ||
COPY --link nginx.conf /etc/nginx/ | ||
COPY --link docker/test.conf /etc/nginx/conf.d/ | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
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