Compare commits

...

10 Commits

4 changed files with 66 additions and 17 deletions

View File

@@ -5,7 +5,7 @@ on:
branches:
- main
tags:
- 'v*'
- "v*"
env:
REGISTRY: git.home.db123.ir
@@ -45,6 +45,7 @@ jobs:
password: ${{ secrets.CICD_PASSWORD }}
- name: Build & push Docker image
id: build
uses: docker/build-push-action@v6
with:
context: .
@@ -56,3 +57,16 @@ jobs:
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:cache,mode=max
- name: Notify build result
if: always()
run: |
if [ "${{ steps.build.outcome }}" = "success" ]; then
curl -s -S -u "server:VKbpgw75KB0biM" \
-d "build & push succeeded ✅" \
https://ntfy.home.db123.ir/build
else
curl -s -S -u "server:VKbpgw75KB0biM" \
-d "build & push FAILED ❌" \
https://ntfy.home.db123.ir/build
fi

View File

@@ -3,7 +3,7 @@ FROM alpine:3.22 AS builder
ENV NGINX_VERSION=1.29.3
# Build dependencies
# Build dependencies
RUN apk add --no-cache \
build-base pcre2-dev zlib-dev openssl-dev linux-headers curl gnupg tar
@@ -24,28 +24,48 @@ RUN ./configure \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-mail \
--with-mail_ssl_module
RUN make -j$(nproc)
RUN make install
--with-stream_realip_module \
--with-http_slice_module \
--with-http_v2_module
RUN make -j$(nproc) && make install
RUN rm -rf /tmp/* && rm -rf /var/cache/apk/*
# --- Stage 2: Runtime ---
FROM alpine:3.22
# Runtime dependencies
RUN apk add --no-cache pcre2 zlib openssl ca-certificates libcap curl
RUN adduser -D -g 'nginx' nginx
RUN apk add --no-cache \
pcre2 zlib openssl ca-certificates tzdata libcap git
RUN addgroup -S nginx && adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx
RUN mkdir -p /var/cache/nginx /etc/nginx/conf.d /etc/nginx/stream_conf.d /usr/share/nginx/html /var/run
RUN chown -R nginx:nginx /var/cache/nginx /var/run /etc/nginx /usr/share/nginx/html
# Copy dummy html
COPY index.html /var/www/html/index.html
# Copy Nginx from builder
COPY --from=builder /usr/sbin/nginx /usr/sbin/nginx
COPY --from=builder /usr/lib/nginx/modules /usr/lib/nginx/modules
COPY --from=builder /etc/nginx /etc/nginx
#COPY --from=builder /usr/lib/nginx/modules /usr/lib/nginx/modules
# Default configuration
COPY nginx.conf /etc/nginx/nginx.conf
@@ -71,4 +91,5 @@ STOPSIGNAL SIGTERM
CMD ["nginx", "-g", "daemon off;"]
# Healthcheck
HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD curl -f http://127.0.0.1:80/ || exit 1
HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD busybox wget --spider -q http://127.0.0.1:80/ || exit 1

View File

@@ -1,9 +1,7 @@
# image-alpine template
# nginx-alpine
you can use this to create docker images easily just remember:
---
1. change username and usergroup of your app from `zxc` to what you desire
2. change `username` in `.gitea/workflows/build.yml` to your username
3. change the dockerfile but note: always use latest alpine image and expose the ports you really need to expose
this image will be used in production and configs are all tailored to the needs of db123 team.
it's based on alpine 3.22 and builds the nginx from source with necessary modules.
you can open an issue if you had any problems using this template.

16
index.html Normal file
View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Nginx</title>
<style></style>
</head>
<body>
<h1 class="header">Nginx is up and running</h1>
<p class="details">
you have setup nginx alpine container successfuly! thanks for using this
image. by db1234719
</p>
</body>
</html>