Skip to content

Commit 19e1011

Browse files
authored
Updates (#2)
1 parent b3c07d2 commit 19e1011

File tree

6 files changed

+76
-43
lines changed

6 files changed

+76
-43
lines changed

.github/workflows/build.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name: "Build"
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
tags:
7-
description: "Extra Tags: comma,separated"
8-
required: false
4+
# NOTE: workflow_dispatch no longer works because arg VERSION=${{ github.ref_name }}
5+
#workflow_dispatch:
6+
# inputs:
7+
# tags:
8+
# description: "Extra Tags: comma,separated"
9+
# required: false
910
release:
1011
types: [published]
1112

@@ -39,8 +40,8 @@ jobs:
3940
id: version
4041
uses: cssnr/update-version-tags-action@v1
4142
with:
42-
tags: ${{ inputs.tags }}
4343
prefix: ""
44+
#tags: ${{ inputs.tags }}
4445

4546
- name: "Debug Version Tags"
4647
continue-on-error: true
@@ -50,7 +51,7 @@ jobs:
5051
5152
- name: "Generate Docker Tags"
5253
id: tags
53-
uses: smashedr/docker-tags-action@v1
54+
uses: cssnr/docker-tags-action@v1
5455
with:
5556
images: "ghcr.io/${{ github.repository }}"
5657
tags: ${{ steps.version.outputs.tags }}
@@ -73,7 +74,7 @@ jobs:
7374
labels: ${{ steps.tags.outputs.labels }}
7475
annotations: ${{ steps.tags.outputs.annotations }}
7576
build-args: |
76-
NGINX_VERSION=${{ github.ref_name }}
77+
VERSION=${{ github.ref_name }}
7778
7879
- name: "Send Failure Notification"
7980
if: ${{ failure() }}

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: "Lint"
22

33
on:
44
workflow_dispatch:
5-
pull_request:
65
push:
76
branches: [master]
7+
pull_request:
88

99
concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}

README.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
[![Image Size](https://badges.cssnr.com/ghcr/size/cssnr/docker-nginx-proxy)](https://github.com/cssnr/docker-nginx-proxy/pkgs/container/node-badges)
2-
[![Image Latest](https://badges.cssnr.com/ghcr/tags/cssnr/docker-nginx-proxy/latest)](https://github.com/cssnr/docker-nginx-proxy/pkgs/container/node-badges)
1+
[![Image Size](https://badges.cssnr.com/ghcr/size/cssnr/docker-nginx-proxy)](https://github.com/cssnr/docker-nginx-proxy/pkgs/container/docker-nginx-proxy)
2+
[![Image Latest](https://badges.cssnr.com/ghcr/tags/cssnr/docker-nginx-proxy/latest)](https://github.com/cssnr/docker-nginx-proxy/pkgs/container/docker-nginx-proxy)
33
[![Image Tags](https://badges.cssnr.com/ghcr/tags/cssnr/docker-nginx-proxy)](https://github.com/cssnr/docker-nginx-proxy/pkgs/container/node-badges)
4+
[![GitHub Tag Major](https://img.shields.io/github/v/tag/cssnr/docker-nginx-proxy?sort=semver&filter=!*.*&logo=git&logoColor=white&labelColor=585858&label=%20)](https://github.com/cssnr/docker-nginx-proxy/tags)
5+
[![GitHub Tag Minor](https://img.shields.io/github/v/tag/cssnr/docker-nginx-proxy?sort=semver&filter=!*.*.*&logo=git&logoColor=white&labelColor=585858&label=%20)](https://github.com/cssnr/docker-nginx-proxy/releases)
46
[![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/docker-nginx-proxy?logo=github)](https://github.com/cssnr/docker-nginx-proxy/releases/latest)
57
[![Workflow Build](https://img.shields.io/github/actions/workflow/status/cssnr/docker-nginx-proxy/build.yaml?logo=cachet&label=build)](https://github.com/cssnr/docker-nginx-proxy/actions/workflows/build.yaml)
68
[![Workflow Lint](https://img.shields.io/github/actions/workflow/status/cssnr/docker-nginx-proxy/lint.yaml?logo=cachet&label=lint)](https://github.com/cssnr/docker-nginx-proxy/actions/workflows/lint.yaml)
@@ -21,6 +23,20 @@ Docker Nginx Proxy Container.
2123

2224
This works quite well as is...
2325

26+
```yaml
27+
services:
28+
nginx:
29+
image: ghcr.io/cssnr/docker-nginx-proxy:latest
30+
environment:
31+
- SERVICE_NAME=app # name of app container
32+
- SERVICE_PORT=8000 # port exposed on app
33+
ports:
34+
- '${PORT:-80}:80' # Host PORT : Container (must be :80)
35+
36+
app:
37+
image: your-app-image # listens on port 8000
38+
```
39+
2440
## Examples
2541
2642
If your app container is called `app` and listens on `3000` this will reverse proxy it to the `PORT` exposed on nginx.
@@ -81,16 +97,17 @@ services:
8197
cpus: '1.0'
8298
memory: 64M
8399
labels:
84-
- traefik.enable=true
85-
- traefik.docker.network=traefik-public
86-
- traefik.constraint-label=traefik-public
87-
- traefik.http.routers.node-badges-http.rule=Host(`badges.cssnr.com`)
88-
- traefik.http.routers.node-badges-http.entrypoints=http
89-
- traefik.http.routers.node-badges-http.middlewares=https-redirect
90-
- traefik.http.routers.node-badges-https.rule=Host(`badges.cssnr.com`)
91-
- traefik.http.routers.node-badges-https.entrypoints=https
92-
- traefik.http.routers.node-badges-https.tls=true
93-
- traefik.http.services.node-badges-https.loadbalancer.server.port=80
100+
- 'traefik.enable=true'
101+
- 'traefik.docker.network=traefik-public'
102+
- 'traefik.constraint-label=traefik-public'
103+
- 'traefik.http.routers.${STACK_NAME?err}-http.rule=Host(`${TRAEFIK_HOST?err}`)'
104+
- 'traefik.http.routers.${STACK_NAME}-http.entrypoints=http'
105+
- 'traefik.http.routers.${STACK_NAME}-http.middlewares=https-redirect'
106+
- 'traefik.http.routers.${STACK_NAME}-https.rule=Host(`${TRAEFIK_HOST}`)'
107+
- 'traefik.http.routers.${STACK_NAME}-https.entrypoints=https'
108+
- 'traefik.http.routers.${STACK_NAME}-https.tls=true'
109+
- 'traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80'
110+
- 'traefik.http.services.${STACK_NAME}.loadbalancer.server.scheme=http'
94111
healthcheck:
95112
test: ['CMD-SHELL', 'curl -sf localhost:80/health-check || exit 1']
96113
interval: 30s
@@ -104,7 +121,7 @@ services:
104121
- traefik-public
105122

106123
app:
107-
image: ghcr.io/smashedr/node-badges:latest
124+
image: ghcr.io/smashedr/node-badges:${VERSION:-latest}
108125
command: 'npm start'
109126
deploy:
110127
mode: global

build.sh

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,51 @@ REGISTRY_HOST="ghcr.io"
66
REGISTRY_USER="cssnr"
77
REGISTRY_REPO="docker-nginx-proxy"
88

9+
DEFAULT_VERSION="mainline"
10+
BUILD_CONTEXT="src"
11+
12+
913
if [ -f ".env" ];then
1014
echo "Sourcing Environment: .env"
15+
set -a
1116
source ".env"
17+
set +a
1218
fi
1319

1420
if [ -z "${VERSION}" ];then
15-
if [ -z "${1}" ];then
16-
read -rp "Version (latest): " VERSION
17-
else
21+
if [ -n "${1}" ];then
1822
VERSION="${1}"
23+
else
24+
read -rp "Version (${DEFAULT_VERSION}): " VERSION
1925
fi
2026
fi
2127

22-
[[ -z "${VERSION}" ]] && VERSION="latest"
28+
[[ -z "${VERSION}" ]] && VERSION="${DEFAULT_VERSION}"
29+
30+
echo "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}"
31+
2332

2433
#if [ -z "${USERNAME}" ];then
2534
# read -rp "Username: " USERNAME
2635
#fi
2736
#if [ -z "${PASSWORD}" ];then
2837
# read -rp "Password: " PASSWORD
2938
#fi
30-
31-
echo "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}"
32-
39+
#
3340
#docker login --username "${USERNAME}" --password "${PASSWORD}" "${REGISTRY_HOST}"
3441
#docker login "${REGISTRY_HOST}"
3542

43+
3644
#docker buildx create --use
37-
#docker buildx build --platform linux/amd64,linux/arm64 \
38-
# -t "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}" nginx
45+
#docker buildx build -t "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}" \
46+
# --platform linux/amd64,linux/arm64 \
47+
# --build-arg VERSION="${VERSION}" \
48+
# "${BUILD_CONTEXT}"
3949

40-
docker build -t "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}" src
50+
docker build -t "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}" \
51+
--build-arg VERSION="${VERSION}" \
52+
"${BUILD_CONTEXT}"
4153

42-
#--build-arg NGINX_VERSION="${VERSION}" \
54+
# --build-arg VERSION="${VERSION}" \
4355

4456
#docker push "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}"

docker-compose.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ services:
44
nginx:
55
image: ghcr.io/cssnr/docker-nginx-proxy:latest
66
environment:
7-
- SERVICE_NAME=app
8-
- SERVICE_PORT=80
7+
- SERVICE_NAME=app # name of app container
8+
- SERVICE_PORT=8000 # port exposed on app
99
ports:
10-
- "80:80"
10+
- "${PORT:-80}:80" # Host PORT : Container (must be :80)
1111

1212
app:
13-
image: your-app-image
13+
image: your-app-image # listens on port 8000

src/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
ARG NGINX_VERSION=1
2-
FROM nginx:${NGINX_VERSION}-alpine-slim
1+
ARG VERSION=1
2+
FROM nginx:${VERSION}-alpine-slim
3+
4+
ARG VERSION
5+
6+
ENV TZ=UTC
37

48
LABEL org.opencontainers.image.source="https://github.com/cssnr/docker-nginx-proxy"
59
LABEL org.opencontainers.image.description="Docker Nginx Proxy"
610
LABEL org.opencontainers.image.authors="smashedr"
7-
8-
ENV TZ=UTC
11+
LABEL org.opencontainers.image.version="${VERSION}"
912

1013
RUN apk add --no-cache curl
1114

12-
COPY nginx.conf /etc/nginx/nginx.conf
13-
1415
COPY --chmod=0755 10-update-config.sh /docker-entrypoint.d
16+
17+
COPY nginx.conf /etc/nginx/nginx.conf

0 commit comments

Comments
 (0)