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

feat: enhance and update workdir and document root #9

Merged
merged 10 commits into from
Nov 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
31 changes: 20 additions & 11 deletions .github/workflows/publish-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ on:
- created

env:
REGISTRY: ghcr.io
USER: alwatr

jobs:
Expand All @@ -36,6 +35,7 @@ jobs:
- path: nginx-cdn
- path: nginx-pwa
- path: nginx-ws
- path: nginx-json

permissions:
contents: read
Expand Down Expand Up @@ -68,14 +68,21 @@ jobs:
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: alwatr-${{ matrix.path }}
key: container/${{ matrix.path }}

- name: 🏗 Log into registry ${{env.REGISTRY}}
- name: 🏗 Log into docker hub registry
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }}
uses: docker/[email protected]
with:
registry: ${{env.REGISTRY}}
username: ${{github.repository_owner}}
username: ${{env.USER}}
password: ${{secrets.DOCKER_HUB_TOKEN}}

- name: 🏗 Log into ghcr.io registry
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }}
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{env.USER}}
password: ${{secrets.GITHUB_TOKEN}}

- name: 🏗 Extract metadata
Expand All @@ -84,7 +91,9 @@ jobs:
uses: docker/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
images: name=${{env.REGISTRY}}/${{env.USER}}/${{matrix.path}},enable=true
images: |
name=ghcr.io/${{env.USER}}/${{matrix.path}},enable=true
name=docker.io/${{env.USER}}/${{matrix.path}},enable=true
tags: |
type=semver,enable=true,pattern={{major}}
type=semver,enable=true,pattern={{major}}.{{minor}}
Expand All @@ -105,8 +114,8 @@ jobs:
BUILD_DATE=${{github.event.repository.updated_at}}
BUILD_REV=${{github.sha}}

- name: 🏗 Sign the image with GitHub OIDC Token
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }}
env:
COSIGN_EXPERIMENTAL: 'true'
run: echo "${{steps.meta.outputs.tags}}" | xargs -I {} cosign sign --yes {}@${{steps.build_and_push.outputs.digest}}
# - name: 🏗 Sign the image with GitHub OIDC Token
# if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }}
# env:
# COSIGN_EXPERIMENTAL: 'true'
# run: echo "${{steps.meta.outputs.tags}}" | xargs -I {} cosign sign --yes {}@${{steps.build_and_push.outputs.digest}}
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Alwatr Accelerated Web Server

High-performance, accelerated NGINX, optimized for serving static content. Enhanced and accelerated by Alwatr.
This is a high-performance version of NGINX, which has been enhanced by Alwatr for the purpose of serving static content efficiently.

## Usage

The right way of using the alwatr nginx is behind kubernetes ingress or simple edge reverse-proxy, then don't config edge stuff like gzip compression, ssl, etc or even config domain or multiple websites.
The recommended method for using the Alwatr Nginx is to place it behind a Kubernetes ingress or a simple edge reverse-proxy like Traefik. In this setup, there's no need to configure edge features such as gzip compression, SSL, etc., or even set up a domain or multiple websites.

```Dockerfile
FROM ghcr.io/alwatr/nginx:1
```

### Serve Progressive Web App

The right way of using the alwatr nginx is behind kubernetes ingress or simple edge reverse-proxy, then don't config edge stuff like gzip compression, ssl, etc or even config domain or multiple websites.
### Serve Progressive Web Apps

```Dockerfile
ARG NODE_VERSION=lts
Expand Down
3 changes: 2 additions & 1 deletion nginx-cdn/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*
!etc/nginx/
!var/www/
!data/

14 changes: 9 additions & 5 deletions nginx-cdn/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM ghcr.io/alwatr/nginx-core:1.1.1
FROM ghcr.io/alwatr/nginx-core:2.0.0

# COPY etc/nginx/ /etc/nginx/
# COPY data/ .
# RUN ls -RlahF /etc/nginx /data

# Default environment for nginx template
ENV NGINX_CLIENT_MAX_BODY_SIZE=1k \
Expand All @@ -20,10 +24,10 @@ ENV NGINX_CLIENT_MAX_BODY_SIZE=1k \
ARG BUILD_REV
ARG BUILD_DATE
LABEL org.opencontainers.image.title="alwatr/nginx-cdn" \
org.opencontainers.image.description="High-performance, accelerated NGINX, optimized for CDN. Enhanced and accelerated by Alwatr." \
org.opencontainers.image.base.name="ghcr.io/alwatr/nginx-core:1.1.1" \
org.opencontainers.image.version="1.1.1" \
org.opencontainers.image.ref.name="1.1.1-n1.25.3-a3.18-slim" \
org.opencontainers.image.description="This is a high-performance version of NGINX, which has been enhanced by Alwatr for the purpose of serving static content efficiently." \
org.opencontainers.image.base.name="ghcr.io/alwatr/nginx-core:2.0.0" \
org.opencontainers.image.version="2.0.0" \
org.opencontainers.image.ref.name="2.0.0-nginx1.25.3-alpine3.18-slim" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REV} \
Expand Down
2 changes: 1 addition & 1 deletion nginx-core/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*
!etc/nginx/
!var/www/
!data/
18 changes: 10 additions & 8 deletions nginx-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM ghcr.io/alwatr/nginx:1.1.1
FROM ghcr.io/alwatr/nginx:2.0.0

RUN apk add --no-cache curl
HEALTHCHECK --interval=30s --timeout=3s --start-period=1s --retries=3 CMD curl -fso /dev/null http://localhost/server-info || exit 1

WORKDIR /data

COPY etc/nginx/ /etc/nginx/
COPY var/www/ /var/www/
RUN ls -RlAhF /etc/nginx/
COPY data/ .
RUN ls -RlahF /etc/nginx /data

# Default environment for nginx template
ENV NGINX_ACCESS_LOG="/var/log/nginx/access.log json" \
Expand All @@ -14,7 +16,7 @@ ENV NGINX_ACCESS_LOG="/var/log/nginx/access.log json" \
NGINX_LIMIT_REQ_ERROR=503 \
NGINX_LIMIT_REQ_LOG=notice \
NGINX_AUTOINDEX=off \
NGINX_DOCUMENT_ROOT=/var/www/html \
NGINX_DOCUMENT_ROOT=/data \
NGINX_FORCE_DOMAIN="" \
NGINX_FORCE_DOMAIN_STATUS=302 \
NGINX_FORCE_REDIRECT_STATUS=302 \
Expand All @@ -40,10 +42,10 @@ ENV NGINX_CLIENT_MAX_BODY_SIZE=10m \
ARG BUILD_REV
ARG BUILD_DATE
LABEL org.opencontainers.image.title="alwatr/nginx-core" \
org.opencontainers.image.description="High-performance, accelerated NGINX, optimized for serving static content. Enhanced and accelerated by Alwatr." \
org.opencontainers.image.base.name="ghcr.io/alwatr/nginx:1.1.1" \
org.opencontainers.image.version="1.1.1-n1.25.3" \
org.opencontainers.image.ref.name="1.1.1-n1.25.3-a3.18-slim" \
org.opencontainers.image.description="HThis is a high-performance version of NGINX, which has been enhanced by Alwatr for the purpose of serving static content efficiently." \
org.opencontainers.image.base.name="ghcr.io/alwatr/nginx:2.0.0" \
org.opencontainers.image.version="2.0.0-nginx1.25.3" \
org.opencontainers.image.ref.name="2.0.0-nginx1.25.3-alpine3.18-slim" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REV} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!--# if expr="$status = 502" -->
<meta http-equiv="refresh" content="2">
<meta http-equiv="refresh" content="2"/>
<!--# endif -->
<title>Error!</title>
<style>
Expand Down
40 changes: 20 additions & 20 deletions nginx-core/var/www/html/index.html → nginx-core/data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>..:: Alwatr Accelerated Web Server ::..</title>
<title>Alwatr Nginx</title>
<style>
:root {
--primary-color: #63459e;
Expand All @@ -16,24 +16,24 @@
font-size: 16px;
}

body {
margin: 0;
font-family: system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
'Roboto',
'Oxygen',
'Ubuntu',
'Cantarell',
'Open Sans',
'Helvetica Neue',
'Arial',
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji',
'Segoe UI Symbol';
}
body {
margin: 0;
font-family: system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
'Roboto',
'Oxygen',
'Ubuntu',
'Cantarell',
'Open Sans',
'Helvetica Neue',
'Arial',
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji',
'Segoe UI Symbol';
}

body::before {
content: '';
Expand Down Expand Up @@ -115,7 +115,7 @@
</head>
<body>
<div class="board">
<h1>Hello World</h1>
<h1>Alwatr Nginx</h1>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 @errorPage;

location @errorPage {
try_files /error.html /_error.html;
}

location = /error.html {
ssi on;
internal;
auth_basic off;
}
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /_error.html;

location = /_error.html {
ssi on;
internal;
auth_basic off;
root /var/www;
}
2 changes: 1 addition & 1 deletion nginx-pwa/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*
!etc/nginx/
!var/www/
!data/
10 changes: 6 additions & 4 deletions nginx-pwa/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM ghcr.io/alwatr/nginx-core:1.1.1

COPY etc/nginx/ /etc/nginx/
RUN ls -RlAhF /etc/nginx/
# COPY data/ .
RUN ls -RlahF /etc/nginx /data

# Default environment for nginx template
ENV NGINX_CLIENT_MAX_BODY_SIZE=1k \
Expand All @@ -18,15 +19,16 @@ ENV NGINX_CLIENT_MAX_BODY_SIZE=1k \
NGINX_EXPIRES_DEFAULT=epoch \
NGINX_LIMIT_REQ_RATE=400 \
NGINX_LIMIT_REQ_BURST=1000 \
NGINX_DISABLE_SYMLINKS=if_not_owner
NGINX_DISABLE_SYMLINKS=if_not_owner \
NGINX_CONFIG_JS_PATH=/data/config.js

ARG BUILD_REV
ARG BUILD_DATE
LABEL org.opencontainers.image.title="alwatr/nginx-pwa" \
org.opencontainers.image.description="High-performance, accelerated NGINX, optimized for serving progressive web applications. Enhanced and accelerated by Alwatr." \
org.opencontainers.image.description="This is a high-performance version of NGINX, which has been enhanced by Alwatr for the purpose of serving PWA efficiently." \
org.opencontainers.image.base.name="ghcr.io/alwatr/nginx-core:1.1.1" \
org.opencontainers.image.version="1.1.1" \
org.opencontainers.image.ref.name="1.1.1-n1.25.3-a3.18-slim" \
org.opencontainers.image.ref.name="2.0.0-nginx1.25.3-alpine3.18-slim" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REV} \
Expand Down
23 changes: 13 additions & 10 deletions nginx-pwa/etc/nginx/entrypoint.d/30-envsubst-on-config-js.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ set -e

ME=$(basename $0)

config_js_envsubst() {
local config_js_path="${NGINX_ENVSUBST_CONFIG_JS_PATH:-/var/www/html/config.js}"
configJsEnvsubst() {
local configJsPath="$NGINX_CONFIG_JS_PATH"
if [ -z "$configJsPath" ] || [ ! -f "$configJsPath" ]
then
return 0
fi

local defined_envs=$(printf '${%s} ' $(env | cut -d= -f1))
[ -f "$config_js_path" ] || return 0
if [ ! -w "$config_js_path" ]; then
echo >&3 "$ME: ERROR: $config_js_path exists, but is not writable"
local definedEnvs=$(printf '${%s} ' $(env | cut -d= -f1))
if [ ! -w "$configJsPath" ]; then
echo >&3 "$ME: ERROR: $configJsPath exists, but is not writable"
return 0
fi
echo >&3 "$ME: Running envsubst on $config_js_path"
envsubst "$defined_envs" < "$config_js_path" > "${config_js_path}.tmp"
mv -f "${config_js_path}.tmp" "$config_js_path"
echo >&3 "$ME: Running envsubst on $configJsPath"
envsubst "$definedEnvs" < "$configJsPath" > "${configJsPath}.tmp"
mv -f "${configJsPath}.tmp" "$configJsPath"
}

config_js_envsubst
configJsEnvsubst

exit 0
2 changes: 1 addition & 1 deletion nginx-ws/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*
!etc/nginx/
!var/www/
!data/
7 changes: 4 additions & 3 deletions nginx-ws/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM ghcr.io/alwatr/nginx-core:1.1.1

COPY etc/nginx/ /etc/nginx/
RUN ls -RlAhF /etc/nginx/
# COPY data/ .
RUN ls -RlahF /etc/nginx /data

# Default environment for nginx template
ENV NGINX_CLIENT_MAX_BODY_SIZE=1k \
Expand All @@ -23,10 +24,10 @@ ENV NGINX_CLIENT_MAX_BODY_SIZE=1k \
ARG BUILD_REV
ARG BUILD_DATE
LABEL org.opencontainers.image.title="alwatr/nginx-ws" \
org.opencontainers.image.description="High-performance, accelerated NGINX, optimized for serving static website. Enhanced and accelerated by Alwatr." \
org.opencontainers.image.description="This is a high-performance version of NGINX, which has been enhanced by Alwatr for the purpose of serving static website content efficiently." \
org.opencontainers.image.base.name="ghcr.io/alwatr/nginx-core:1.1.1" \
org.opencontainers.image.version="1.1.1" \
org.opencontainers.image.ref.name="1.1.1-n1.25.3-a3.18-slim" \
org.opencontainers.image.ref.name="2.0.0-nginx1.25.3-alpine3.18-slim" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REV} \
Expand Down
2 changes: 1 addition & 1 deletion nginx/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*
!etc/nginx/
!var/www/
!data/
10 changes: 5 additions & 5 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
FROM docker.io/library/nginx:1.25.3-alpine3.18-slim

RUN rm -rfv /docker-entrypoint* /etc/nginx/conf.d/* /etc/nginx/nginx.conf /var/www/html /usr/share/nginx/html
RUN rm -rfv /docker-entrypoint* /etc/nginx/conf.d/* /etc/nginx/nginx.conf /var/www/html /usr/share/nginx/html /data
COPY etc/nginx/ /etc/nginx/
RUN chmod a+rx /etc/nginx/entrypoint.sh /etc/nginx/entrypoint.d/*.sh
RUN ls -RlAhF /etc/nginx/

EXPOSE 80
STOPSIGNAL SIGQUIT
WORKDIR /var/www/html/
WORKDIR /data
ENTRYPOINT ["/etc/nginx/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

ARG BUILD_REV
ARG BUILD_DATE
LABEL org.opencontainers.image.title="alwatr/nginx" \
org.opencontainers.image.description="NGINX web server slim (light), packaged by Alwatr." \
org.opencontainers.image.description="The slim (lightweight) version of the NGINX web server, packaged by Alwatr." \
org.opencontainers.image.base.name="docker.io/library/nginx:1.25.3-alpine3.18-slim" \
org.opencontainers.image.version="1.1.1-n1.25.3" \
org.opencontainers.image.ref.name="1.1.1-n1.25.3-a3.18-slim" \
org.opencontainers.image.version="1.25.3" \
org.opencontainers.image.ref.name="1.25.3-alpine3.18-slim" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REV} \
Expand Down
Loading