Skip to content

Commit fb51d27

Browse files
authored
Add GZIP_TYPES Option (#3)
1 parent 19e1011 commit fb51d27

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

.github/workflows/build.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
uses: cssnr/update-version-tags-action@v1
4242
with:
4343
prefix: ""
44+
release: true
4445
#tags: ${{ inputs.tags }}
4546

4647
- name: "Debug Version Tags"
@@ -64,6 +65,17 @@ jobs:
6465
echo "labels: ${{ steps.tags.outputs.labels }}"
6566
echo "annotations: ${{ steps.tags.outputs.annotations }}"
6667
68+
- name: "Parse Nginx Version"
69+
uses: madhead/semver-utils@latest
70+
id: semver
71+
with:
72+
version: ${{ github.ref_name }}
73+
74+
- name: "Debug Nginx Version"
75+
continue-on-error: true
76+
run: |
77+
echo "NGINX_VERSION: ${{ steps.semver.outputs.release }}"
78+
6779
- name: "Build and Push"
6880
uses: docker/build-push-action@v6
6981
with:
@@ -75,6 +87,7 @@ jobs:
7587
annotations: ${{ steps.tags.outputs.annotations }}
7688
build-args: |
7789
VERSION=${{ github.ref_name }}
90+
NGINX_VERSION=${{ steps.semver.outputs.release }}
7891
7992
- name: "Send Failure Notification"
8093
if: ${{ failure() }}

build.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ if [ -f ".env" ];then
1717
set +a
1818
fi
1919

20-
if [ -z "${VERSION}" ];then
21-
if [ -n "${1}" ];then
22-
VERSION="${1}"
23-
else
24-
read -rp "Version (${DEFAULT_VERSION}): " VERSION
25-
fi
26-
fi
20+
VERSION="${1}"
21+
#if [ -z "${VERSION}" ];then
22+
# if [ -n "${1}" ];then
23+
# VERSION="${1}"
24+
# else
25+
# read -rp "Version (${DEFAULT_VERSION}): " VERSION
26+
# fi
27+
#fi
2728

2829
[[ -z "${VERSION}" ]] && VERSION="${DEFAULT_VERSION}"
2930

30-
echo "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}"
31+
echo "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:latest"
3132

3233

3334
#if [ -z "${USERNAME}" ];then
@@ -47,8 +48,9 @@ echo "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}"
4748
# --build-arg VERSION="${VERSION}" \
4849
# "${BUILD_CONTEXT}"
4950

50-
docker build -t "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}" \
51-
--build-arg VERSION="${VERSION}" \
51+
docker build -t "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:latest" \
52+
--build-arg VERSION="latest" \
53+
--build-arg NGINX_VERSION="${VERSION}" \
5254
"${BUILD_CONTEXT}"
5355

5456
# --build-arg VERSION="${VERSION}" \

src/10-update-config.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ echo "SERVICE_PORT: ${SERVICE_PORT}"
1313
sed "s/SERVICE_PORT/${SERVICE_PORT}/g" -i /etc/nginx/nginx.conf
1414
sed "s/SERVICE_NAME/${SERVICE_NAME}/g" -i /etc/nginx/nginx.conf
1515

16+
if [ -n "${GZIP_TYPES}" ];then
17+
echo "GZIP_TYPES: ${GZIP_TYPES}"
18+
cat <<EOF > /etc/nginx/conf.d/http.gzip.conf
19+
gzip on;
20+
gzip_min_length 1000;
21+
gzip_proxied any;
22+
gzip_types ${GZIP_TYPES};
23+
EOF
24+
fi
25+
1626
echo "${0} - Done"
1727

1828
nginx -version ||:

src/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ARG VERSION=1
2-
FROM nginx:${VERSION}-alpine-slim
1+
ARG NGINX_VERSION=1
2+
FROM nginx:${NGINX_VERSION}-alpine-slim
33

44
ARG VERSION
55

@@ -10,7 +10,7 @@ LABEL org.opencontainers.image.description="Docker Nginx Proxy"
1010
LABEL org.opencontainers.image.authors="smashedr"
1111
LABEL org.opencontainers.image.version="${VERSION}"
1212

13-
RUN apk add --no-cache curl
13+
RUN apk add --no-cache curl && rm -rf /etc/nginx/conf.d/default.conf
1414

1515
COPY --chmod=0755 10-update-config.sh /docker-entrypoint.d
1616

src/nginx.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ http {
1919

2020
access_log /dev/stdout main;
2121

22+
include /etc/nginx/conf.d/http.*;
23+
2224
server {
2325
listen 80;
2426

0 commit comments

Comments
 (0)