Skip to content

Commit

Permalink
Add docker build and release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bad-mushroom committed Jun 21, 2022
1 parent 47297ae commit ee73451
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .docker/nginx.conf
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;
}

}
14 changes: 14 additions & 0 deletions .docker/supervisord.conf
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
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
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
30 changes: 30 additions & 0 deletions Dockerfile
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"]
4 changes: 4 additions & 0 deletions README.md
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.

0 comments on commit ee73451

Please sign in to comment.