-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
schedule: | ||
- cron: '0 2 * * *' | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: self-hosted | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Build Docker image (no push) | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile-1.25 | ||
tags: distrolessdevops/nginx-distroless:1.25 | ||
|
||
push: | ||
runs-on: self-hosted | ||
needs: build | ||
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' | ||
steps: | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile-1.25 | ||
push: true | ||
tags: distrolessdevops/nginx-distroless:1.25.3 | ||
|
||
- name: Logout from Docker Hub | ||
run: docker logout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Use NGINX Unprivileged as the base image | ||
FROM nginxinc/nginx-unprivileged:mainline-bookworm AS base | ||
|
||
# Use distroless as the final base image | ||
FROM gcr.io/distroless/base-debian12:nonroot AS final | ||
|
||
# Copy NGINX binary and configuration files | ||
COPY --from=base /usr/sbin/nginx /usr/sbin/nginx | ||
COPY --from=base /etc/nginx /etc/nginx | ||
|
||
# Copy NGINX HTML directory | ||
COPY --from=base /usr/share/nginx/html /usr/share/nginx/html | ||
|
||
# Copy NGINX cache and log directories with proper permissions | ||
COPY --from=base --chmod=777 /var/cache/nginx /var/cache/nginx | ||
COPY --from=base --chmod=777 /var/log/nginx /var/log/nginx | ||
|
||
# Copy required shared libraries | ||
COPY --from=base /lib/x86_64-linux-gnu/libcrypt.so.1 \ | ||
/lib/x86_64-linux-gnu/libpcre2-8.so.0 \ | ||
/lib/x86_64-linux-gnu/libssl.so.3 \ | ||
/lib/x86_64-linux-gnu/libcrypto.so.3 \ | ||
/lib/x86_64-linux-gnu/libz.so.1 \ | ||
/lib/x86_64-linux-gnu/ | ||
|
||
# Set the user to run NGINX | ||
USER nonroot | ||
|
||
# Expose the NGINX port | ||
EXPOSE 8080 | ||
|
||
# Start NGINX | ||
CMD ["/usr/sbin/nginx", "-g", "daemon off;"] |