mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 01:38:15 +00:00
Merge pull request #1865 from nginx-proxy/container-version
Add and display nginx-proxy version
This commit is contained in:
commit
54dd5d1ef0
8
.github/workflows/dockerhub.yml
vendored
8
.github/workflows/dockerhub.yml
vendored
@ -53,12 +53,16 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Retrieve version
|
||||||
|
run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build and push the Debian based image
|
- name: Build and push the Debian based image
|
||||||
id: docker_build_debian
|
id: docker_build_debian
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
|
build-args: NGINX_PROXY_VERSION=${{ env.GIT_DESCRIBE }}
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.docker_meta_debian.outputs.tags }}
|
tags: ${{ steps.docker_meta_debian.outputs.tags }}
|
||||||
@ -101,12 +105,16 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Retrieve version
|
||||||
|
run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build and push the Alpine based image
|
- name: Build and push the Alpine based image
|
||||||
id: docker_build_alpine
|
id: docker_build_alpine
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile.alpine
|
file: Dockerfile.alpine
|
||||||
|
build-args: NGINX_PROXY_VERSION=${{ env.GIT_DESCRIBE }}
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.docker_meta_alpine.outputs.tags }}
|
tags: ${{ steps.docker_meta_alpine.outputs.tags }}
|
||||||
|
15
Dockerfile
15
Dockerfile
@ -39,6 +39,14 @@ RUN git clone https://github.com/nginx-proxy/forego/ \
|
|||||||
FROM nginx:1.21.5
|
FROM nginx:1.21.5
|
||||||
LABEL maintainer="Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag)"
|
LABEL maintainer="Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag)"
|
||||||
|
|
||||||
|
ARG NGINX_PROXY_VERSION
|
||||||
|
# Add DOCKER_GEN_VERSION environment variable
|
||||||
|
# Because some external projects rely on it
|
||||||
|
ARG DOCKER_GEN_VERSION
|
||||||
|
ENV NGINX_PROXY_VERSION=${NGINX_PROXY_VERSION} \
|
||||||
|
DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
|
||||||
|
DOCKER_HOST=unix:///tmp/docker.sock
|
||||||
|
|
||||||
# Install wget and install/updates certificates
|
# Install wget and install/updates certificates
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y -q --no-install-recommends \
|
&& apt-get install -y -q --no-install-recommends \
|
||||||
@ -58,17 +66,10 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
|||||||
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
||||||
COPY --from=dockergen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
COPY --from=dockergen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
||||||
|
|
||||||
# Add DOCKER_GEN_VERSION environment variable
|
|
||||||
# Because some external projects rely on it
|
|
||||||
ARG DOCKER_GEN_VERSION
|
|
||||||
ENV DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION}
|
|
||||||
|
|
||||||
COPY network_internal.conf /etc/nginx/
|
COPY network_internal.conf /etc/nginx/
|
||||||
|
|
||||||
COPY . /app/
|
COPY . /app/
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
|
|
||||||
ENV DOCKER_HOST unix:///tmp/docker.sock
|
|
||||||
|
|
||||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||||
CMD ["forego", "start", "-r"]
|
CMD ["forego", "start", "-r"]
|
||||||
|
@ -40,6 +40,14 @@ RUN git clone https://github.com/nginx-proxy/forego/ \
|
|||||||
FROM nginx:1.21.5-alpine
|
FROM nginx:1.21.5-alpine
|
||||||
LABEL maintainer="Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag)"
|
LABEL maintainer="Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag)"
|
||||||
|
|
||||||
|
ARG NGINX_PROXY_VERSION
|
||||||
|
# Add DOCKER_GEN_VERSION environment variable
|
||||||
|
# Because some external projects rely on it
|
||||||
|
ARG DOCKER_GEN_VERSION
|
||||||
|
ENV NGINX_PROXY_VERSION=${NGINX_PROXY_VERSION} \
|
||||||
|
DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
|
||||||
|
DOCKER_HOST=unix:///tmp/docker.sock
|
||||||
|
|
||||||
# Install wget and install/updates certificates
|
# Install wget and install/updates certificates
|
||||||
RUN apk add --no-cache --virtual .run-deps \
|
RUN apk add --no-cache --virtual .run-deps \
|
||||||
ca-certificates bash wget openssl \
|
ca-certificates bash wget openssl \
|
||||||
@ -55,17 +63,10 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
|||||||
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
||||||
COPY --from=dockergen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
COPY --from=dockergen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
||||||
|
|
||||||
# Add DOCKER_GEN_VERSION environment variable
|
|
||||||
# Because some external projects rely on it
|
|
||||||
ARG DOCKER_GEN_VERSION
|
|
||||||
ENV DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION}
|
|
||||||
|
|
||||||
COPY network_internal.conf /etc/nginx/
|
COPY network_internal.conf /etc/nginx/
|
||||||
|
|
||||||
COPY . /app/
|
COPY . /app/
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
|
|
||||||
ENV DOCKER_HOST unix:///tmp/docker.sock
|
|
||||||
|
|
||||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||||
CMD ["forego", "start", "-r"]
|
CMD ["forego", "start", "-r"]
|
||||||
|
4
Makefile
4
Makefile
@ -6,10 +6,10 @@ build-webserver:
|
|||||||
docker build -t web test/requirements/web
|
docker build -t web test/requirements/web
|
||||||
|
|
||||||
build-nginx-proxy-test-debian:
|
build-nginx-proxy-test-debian:
|
||||||
docker build -t nginxproxy/nginx-proxy:test .
|
docker build --build-arg NGINX_PROXY_VERSION="test" -t nginxproxy/nginx-proxy:test .
|
||||||
|
|
||||||
build-nginx-proxy-test-alpine:
|
build-nginx-proxy-test-alpine:
|
||||||
docker build -f Dockerfile.alpine -t nginxproxy/nginx-proxy:test .
|
docker build --build-arg NGINX_PROXY_VERSION="test" -f Dockerfile.alpine -t nginxproxy/nginx-proxy:test .
|
||||||
|
|
||||||
test-debian: build-webserver build-nginx-proxy-test-debian
|
test-debian: build-webserver build-nginx-proxy-test-debian
|
||||||
test/pytest.sh
|
test/pytest.sh
|
||||||
|
@ -29,6 +29,12 @@ function _parse_false() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _print_version {
|
||||||
|
if [[ -n "${NGINX_PROXY_VERSION:-}" ]]; then
|
||||||
|
echo "Info: running nginx-proxy version ${NGINX_PROXY_VERSION}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function _check_unix_socket() {
|
function _check_unix_socket() {
|
||||||
# Warn if the DOCKER_HOST socket does not exist
|
# Warn if the DOCKER_HOST socket does not exist
|
||||||
if [[ ${DOCKER_HOST} == unix://* ]]; then
|
if [[ ${DOCKER_HOST} == unix://* ]]; then
|
||||||
@ -96,6 +102,8 @@ function _setup_dhparam() {
|
|||||||
|
|
||||||
# Run the init logic if the default CMD was provided
|
# Run the init logic if the default CMD was provided
|
||||||
if [[ $* == 'forego start -r' ]]; then
|
if [[ $* == 'forego start -r' ]]; then
|
||||||
|
_print_version
|
||||||
|
|
||||||
_check_unix_socket
|
_check_unix_socket
|
||||||
|
|
||||||
_resolvers
|
_resolvers
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
|
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
|
||||||
|
|
||||||
|
{{ $nginx_proxy_version := coalesce $.Env.NGINX_PROXY_VERSION "" }}
|
||||||
{{ $external_http_port := coalesce $.Env.HTTP_PORT "80" }}
|
{{ $external_http_port := coalesce $.Env.HTTP_PORT "80" }}
|
||||||
{{ $external_https_port := coalesce $.Env.HTTPS_PORT "443" }}
|
{{ $external_https_port := coalesce $.Env.HTTPS_PORT "443" }}
|
||||||
{{ $debug_all := $.Env.DEBUG }}
|
{{ $debug_all := $.Env.DEBUG }}
|
||||||
@ -48,6 +49,10 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if ne $nginx_proxy_version "" }}
|
||||||
|
# nginx-proxy version : {{ $nginx_proxy_version }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
|
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
|
||||||
# scheme used to connect to this server
|
# scheme used to connect to this server
|
||||||
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
|
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
|
||||||
|
@ -22,3 +22,8 @@ def test_forwards_to_web2(docker_compose, nginxproxy):
|
|||||||
def test_ipv6_is_disabled_by_default(docker_compose, nginxproxy):
|
def test_ipv6_is_disabled_by_default(docker_compose, nginxproxy):
|
||||||
with pytest.raises(ConnectionError):
|
with pytest.raises(ConnectionError):
|
||||||
nginxproxy.get("http://nginx-proxy/port", ipv6=True)
|
nginxproxy.get("http://nginx-proxy/port", ipv6=True)
|
||||||
|
|
||||||
|
|
||||||
|
def test_container_version_is_displayed(docker_compose, nginxproxy):
|
||||||
|
conf = nginxproxy.get_conf().decode('ASCII')
|
||||||
|
assert "# nginx-proxy version : test" in conf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user