diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml new file mode 100644 index 0000000..484fe8b --- /dev/null +++ b/.forgejo/workflows/ci.yaml @@ -0,0 +1,56 @@ +name: ci + +on: + schedule: + - cron: "0 10 * * *" + push: + branches: + - "**" + tags: + - "v*.*.*" + pull_request: + branches: + - "main" + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + registry: code.tjo.space + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: code.tjo.space/tjo-cloud/nginx + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push WEB + uses: docker/build-push-action@v6 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..96fdbef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +ARG NGINX_VERSION=1.27.1 +ARG GEOIP2_VERSION=3.4 + +# Build +FROM nginx:$NGINX_VERSION AS build + +RUN mkdir -p /var/lib/GeoIP/ + +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + libpcre2-dev \ + zlib1g-dev \ + libgeoip-dev \ + libmaxminddb-dev \ + wget \ + git + +RUN cd /opt \ + && git clone --depth 1 -b $GEOIP2_VERSION --single-branch https://github.com/leev/ngx_http_geoip2_module.git \ + && wget -O - http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz | tar zxfv - \ + && mv /opt/nginx-$NGINX_VERSION /opt/nginx \ + && cd /opt/nginx \ + && ./configure --with-compat --add-dynamic-module=/opt/ngx_http_geoip2_module --with-stream \ + && make modules + +# Production +FROM nginx:$NGINX_VERSION AS production + +COPY --from=build /opt/nginx/objs/ngx_http_geoip2_module.so /usr/lib/nginx/modules +COPY --from=build /opt/nginx/objs/ngx_stream_geoip2_module.so /usr/lib/nginx/modules + +RUN apt-get update \ + && apt-get install -y --no-install-recommends --no-install-suggests libmaxminddb0 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && chmod -R 644 /usr/lib/nginx/modules/ngx_http_geoip2_module.so \ + && chmod -R 644 /usr/lib/nginx/modules/ngx_stream_geoip2_module.so