Compare commits

...

10 Commits

4 changed files with 66 additions and 17 deletions

View File

@@ -5,7 +5,7 @@ on:
branches: branches:
- main - main
tags: tags:
- 'v*' - "v*"
env: env:
REGISTRY: git.home.db123.ir REGISTRY: git.home.db123.ir
@@ -45,6 +45,7 @@ jobs:
password: ${{ secrets.CICD_PASSWORD }} password: ${{ secrets.CICD_PASSWORD }}
- name: Build & push Docker image - name: Build & push Docker image
id: build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: . context: .
@@ -56,3 +57,16 @@ jobs:
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} ${{ 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-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 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

@@ -24,28 +24,48 @@ RUN ./configure \
--pid-path=/var/run/nginx.pid \ --pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \ --lock-path=/var/run/nginx.lock \
--with-http_ssl_module \ --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_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 \
--with-stream_ssl_module \ --with-stream_ssl_module \
--with-mail \ --with-stream_realip_module \
--with-mail_ssl_module --with-http_slice_module \
RUN make -j$(nproc) --with-http_v2_module
RUN make install RUN make -j$(nproc) && make install
RUN rm -rf /tmp/* && rm -rf /var/cache/apk/*
# --- Stage 2: Runtime --- # --- Stage 2: Runtime ---
FROM alpine:3.22 FROM alpine:3.22
# Runtime dependencies # Runtime dependencies
RUN apk add --no-cache pcre2 zlib openssl ca-certificates libcap curl RUN apk add --no-cache \
RUN adduser -D -g 'nginx' nginx 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 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 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 Nginx from builder
COPY --from=builder /usr/sbin/nginx /usr/sbin/nginx 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 /etc/nginx /etc/nginx
#COPY --from=builder /usr/lib/nginx/modules /usr/lib/nginx/modules
# Default configuration # Default configuration
COPY nginx.conf /etc/nginx/nginx.conf COPY nginx.conf /etc/nginx/nginx.conf
@@ -71,4 +91,5 @@ STOPSIGNAL SIGTERM
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]
# Healthcheck # 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 this image will be used in production and configs are all tailored to the needs of db123 team.
2. change `username` in `.gitea/workflows/build.yml` to your username it's based on alpine 3.22 and builds the nginx from source with necessary modules.
3. change the dockerfile but note: always use latest alpine image and expose the ports you really need to expose
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>