Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Dockerfile to Folder for OSS #182

Merged
merged 2 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ performance-test: ## Run performance tests
docker run -v ${PWD}:/home/nginx/ --rm nginx-agent-benchmark:1.0.0

integration-test: local-deb-package
PACKAGE=${PACKAGE_NAME} go test ./test/integration/api
PACKAGE=${PACKAGE_NAME} DOCKER_IMAGE=${DOCKER_IMAGE} go test ./test/integration/api

test-bench: ## Run benchmark tests
cd test/performance && GOWORK=off CGO_ENABLED=0 go test -mod=vendor -count 5 -timeout 2m -bench=. -benchmem metrics_test.go
Expand Down
49 changes: 49 additions & 0 deletions scripts/docker/nginx-oss/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

set -e
set -x
set -euxo pipefail

handle_term()
{
echo "received TERM signal"
echo "stopping nginx-agent ..."
kill -TERM "${agent_pid}" 2>/dev/null
echo "stopping nginx ..."
kill -TERM "${nginx_pid}" 2>/dev/null
}

trap 'handle_term' TERM

# Launch nginx
echo "starting nginx ..."
/usr/sbin/nginx -g "daemon off;" &

nginx_pid=$!

cp /agent/nginx-agent.conf /etc/nginx-agent/nginx-agent.conf
cat /etc/nginx-agent/nginx-agent.conf

# start nginx-agent, pass args
echo "starting nginx-agent ..."
nginx-agent "$@" &

agent_pid=$!

if [ $? != 0 ]; then
echo "couldn't start the agent, please check the log file"
exit 1
fi

wait_term()
{
wait ${agent_pid}
trap - TERM
kill -QUIT "${nginx_pid}" 2>/dev/null
echo "waiting for nginx to stop..."
wait ${nginx_pid}
}

wait_term

echo "nginx-agent process has stopped, exiting."
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
FROM ubuntu:22.04 as install
ARG DOCKER_IMAGE
FROM ${DOCKER_IMAGE} as install
LABEL maintainer="NGINX Agent Maintainers <[email protected]>"

ARG PACKAGE
ARG AGENT_CONF
ARG NGINX_CONF
ARG ENTRY_POINT

WORKDIR /agent
COPY ./ /agent
COPY ./test/testdata/entrypoint.sh /agent/entrypoint.sh
COPY ./test/testdata/configs/integration/api/nginx-agent.conf /agent/nginx-agent.conf
COPY ./test/testdata/configs/integration/api/nginx.conf /agent/nginx.conf
COPY $ENTRY_POINT /agent/entrypoint.sh
COPY $AGENT_CONF /agent/nginx-agent.conf
COPY $NGINX_CONF /agent/nginx.conf

RUN set -x \
&& addgroup --system --gid 101 nginx \
Expand Down
5 changes: 3 additions & 2 deletions test/integration/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/go-resty/resty/v2"
"github.com/stretchr/testify/assert"
"github.com/testcontainers/testcontainers-go/modules/compose"
"github.com/testcontainers/testcontainers-go/modules/compose"
wait "github.com/testcontainers/testcontainers-go/wait"
)

Expand All @@ -33,7 +33,8 @@ func TestAPI_setupTestContainer(t *testing.T) {

assert.NoError(t, comp.
WaitForService("agent", wait.ForLog("OneTimeRegistration completed")).WithEnv(map[string]string{
"PACKAGE": os.Getenv("PACKAGE"),
"PACKAGE": os.Getenv("PACKAGE"),
"DOCKER_IMAGE": os.Getenv("DOCKER_IMAGE"),
}).
Up(ctx, compose.Wait(true)), "compose.Up()")
}
Expand Down
8 changes: 6 additions & 2 deletions test/integration/api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ services:
agent:
build:
context: ../../../
dockerfile: ./test/docker/integration/api/Dockerfile
dockerfile: ./scripts/docker/nginx-oss/ubuntu/Dockerfile
args:
- PACKAGE
PACKAGE: ${PACKAGE}
DOCKER_IMAGE: ${DOCKER_IMAGE}
AGENT_CONF: "./test/testdata/configs/integration/api/nginx-agent.conf"
NGINX_CONF: "./test/testdata/configs/integration/api/nginx.conf"
ENTRY_POINT: "./scripts/docker/nginx-oss/entrypoint.sh"
ports:
- 9091:9091
networks:
Expand Down
1 change: 0 additions & 1 deletion test/integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ require (
)

replace (

// https://github.com/cucumber/godog/releases/tag/v0.12.0 - this version breaks
github.com/cucumber/godog => github.com/cucumber/godog v0.11.0
github.com/docker/cli => github.com/docker/cli v20.10.3-0.20221013132413-1d6c6e2367e2+incompatible // 22.06 master branch
Expand Down