-
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.
Add docker build and release workflow
- Loading branch information
1 parent
47297ae
commit ee73451
Showing
5 changed files
with
135 additions
and
0 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,33 @@ | ||
server { | ||
listen 80; | ||
root /var/www/public; | ||
server_name petstxt; | ||
index index.html; | ||
|
||
client_max_body_size 2; | ||
|
||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
add_header X-Frame-Options "SAMEORIGIN"; | ||
add_header X-Content-Type-Options nosniff; | ||
add_header X-XSS-Protection "1; mode=block"; | ||
add_header Content-Security-Policy "frame-ancestors 'self' *.petstxt.org"; | ||
|
||
location = /robots.txt { | ||
allow all; | ||
log_not_found off; | ||
access_log off; | ||
} | ||
|
||
location = /favicon.ico { | ||
allow all; | ||
log_not_found off; | ||
access_log off; | ||
} | ||
|
||
location / { | ||
try_files $uri $uri/ /index.html?$args; | ||
} | ||
|
||
} |
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,14 @@ | ||
[supervisord] | ||
nodaemon=true | ||
logfile=/dev/null | ||
logfile_maxbytes=0 | ||
pidfile=/run/supervisord.pid | ||
|
||
[program:nginx] | ||
command=nginx -g 'daemon off;' | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
autorestart=false | ||
startretries=0 |
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 |
---|---|---|
@@ -1 +1,55 @@ | ||
|
||
name: Build Release and Push to DockerHub | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
DOCKER_HUB_REPOSITORY: petstxt-website | ||
IMAGE_TAG: 'latest' | ||
|
||
steps: | ||
|
||
# Checkout repo | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
# Tag and create GitHub release | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ github.run_id }} | ||
release_name: Release ${{ github.sha }} | ||
body: | | ||
Automated Release | ||
- ${{ github.repository }} | ||
- ${{ github.ref }} | ||
- ${{ github.sha }} | ||
draft: false | ||
prerelease: false | ||
|
||
# Install Docker | ||
- name: Install Docker | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
# DockerHub auth | ||
- name: Login to Docker | ||
run: docker login --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD | ||
|
||
# Build and tag image | ||
- name: Build Image | ||
run: docker build -t $DOCKER_HUB_USERNAME/$DOCKER_HUB_REPOSITORY:$IMAGE_TAG . | ||
|
||
# Push image to DockerHub | ||
- name: Push Image | ||
run: docker push $DOCKER_HUB_USERNAME/$DOCKER_HUB_REPOSITORY:$IMAGE_TAG |
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,30 @@ | ||
FROM alpine:latest | ||
LABEL Mainainter="Chris <[email protected]>" \ | ||
Description="A lightweight and efficient Nginx container based on Alpine linux." | ||
|
||
# Install core dependencies | ||
RUN apk update && \ | ||
apk upgrade && \ | ||
apk add nginx \ | ||
supervisor | ||
|
||
# Set working directory | ||
WORKDIR /var/www | ||
|
||
# Configure supervisord | ||
COPY .docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
|
||
# Copy app | ||
COPY . ./ | ||
|
||
# Set user/group | ||
RUN chown -R nobody.nobody /var/www | ||
|
||
# Cleanup | ||
RUN rm -rf /var/cache/apk/ | ||
|
||
# Expose NGINX on port 80 | ||
EXPOSE 80 | ||
|
||
# Start Nginx | FPM | ||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |
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,4 @@ | ||
# Pets.txt Website | ||
|
||
This is the repo for the (www.petstxt.org)[https://www.petstxt.org] website. | ||
|