Skip to content

Commit

Permalink
Adding to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
smashedr committed Jul 23, 2024
0 parents commit 4159374
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build

on:
workflow_dispatch:
inputs:
tags:
description: "Extra Tags: comma,separated"
required: false
release:
types: [published]

env:
REGISTRY: "ghcr.io"

jobs:
build:
name: "Build"
runs-on: ubuntu-latest
timeout-minutes: 25

steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Setup Buildx"
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64

- name: "Docker Login"
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ vars.GHCR_USER }}
password: ${{ secrets.GHCR_PASS }}

- name: "Generate Tags"
id: tags
uses: smashedr/docker-tags-action@master
with:
images: "${{ env.REGISTRY }}/${{ github.repository }}"
extra: ${{ inputs.tags }}

- name: "Build and Push"
uses: docker/build-push-action@v4
with:
context: nginx
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.tags }}
17 changes: 17 additions & 0 deletions .github/workflows/tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Tags"

on:
release:
types: [published]

jobs:
tags:
name: "Tags"
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: "Update Tags"
uses: cssnr/update-version-tags-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
*.iml
.vscode/
20 changes: 20 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": false,
"singleQuote": true,
"overrides": [
{
"files": ["**/*.json", "**/*.yaml", "**/*.yml"],
"options": {
"singleQuote": false
}
},
{
"files": ["**/*.json", "**/*.yaml", "**/*.yml"],
"options": {
"tabWidth": 2
}
}
]
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[![Build](https://img.shields.io/github/actions/workflow/status/cssnr/docker-nginx-static/build.yaml?logo=github&logoColor=white&label=build)](https://github.com/cssnr/docker-nginx-static/actions/workflows/build.yaml)
[![Tags](https://img.shields.io/github/actions/workflow/status/cssnr/docker-nginx-static/tags.yaml?logo=github&logoColor=white&label=tags)](https://github.com/cssnr/docker-nginx-static/actions/workflows/tags.yaml)

# Docker Nginx Static

Docker Static Web Server

Coming Soon...
37 changes: 37 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -e

REGISTRY_HOST="ghcr.io"
REGISTRY_USER="smashedr"
REGISTRY_REPO="docker-nginx-static"

if [ -f ".env" ];then
echo "Sourcing Environment: .env"
source ".env"
fi

if [ -z "${VERSION}" ];then
if [ -z "${1}" ];then
read -rp "Version: " VERSION
else
VERSION="${1}"
fi
fi
#if [ -z "${USERNAME}" ];then
# read -rp "Username: " USERNAME
#fi
#if [ -z "${PASSWORD}" ];then
# read -rp "Password: " PASSWORD
#fi

echo "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}"

#docker login --username "${USERNAME}" --password "${PASSWORD}" "${REGISTRY_HOST}"
docker login "${REGISTRY_HOST}"

docker buildx create --use
docker buildx build --platform linux/amd64,linux/arm64 --push \
-t "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}" nginx

#docker push "${REGISTRY_HOST}/${REGISTRY_USER}/${REGISTRY_REPO}:${VERSION}"
48 changes: 48 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: "3.8"

services:
nginx:
build:
context: nginx
image: ghcr.io/smashedr/docker-nginx-static:latest
#environment:
# SUID: 1000
# STATIC: /static
deploy:
mode: global
resources:
limits:
cpus: "1.0"
memory: 25M
volumes:
- static:/static
ports:
- "8000:80"

openssh-server:
image: lscr.io/linuxserver/openssh-server:latest
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- SUDO_ACCESS=false
- PASSWORD_ACCESS=true
- USER_NAME=${USER_NAME:-test}
- USER_PASSWORD=${USER_PASSWORD:-test123}
- DOCKER_MODS=linuxserver/mods:openssh-server-rsync
- LOG_STDOUT=true
deploy:
mode: global
resources:
limits:
cpus: "1.0"
memory: 25M
volumes:
- config:/config
- static:/static
ports:
- "${DOCKER_PORT:-2222}:2222"

volumes:
static:
config:
9 changes: 9 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM nginx:alpine-slim

LABEL org.opencontainers.image.source="https://github.com/cssnr/docker-nginx-static"

ENV TZ=UTC

COPY nginx.conf /etc/nginx/nginx.conf

COPY --chmod=0755 perms.sh /docker-entrypoint.d/
29 changes: 29 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
user nginx;
worker_processes auto;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

error_log /dev/stderr warn;

http {
sendfile on;
charset utf-8;
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$time_local - $http_x_real_ip ($realip_remote_addr) '
'[$status] $body_bytes_sent $remote_user "$request" '
'"$http_referer" "$http_user_agent"';
access_log /dev/stdout main;

server {
listen 80;
location / {
root /static;
autoindex on;
}
}
}
13 changes: 13 additions & 0 deletions nginx/perms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh

set -e

echo "Running: ${0}"

echo "STATIC: ${STATIC:-/static}"
echo "SUID: ${SUID:-1000}"

echo "Setting Permissions ${SUID:-1000}:${SUID:-1000} on ${STATIC:-/static}"
chown -R "${SUID:-1000}:${SUID:-1000}" "${STATIC:-/static}"

echo "Done"

0 comments on commit 4159374

Please sign in to comment.