Skip to content

Commit

Permalink
Add files for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDaniel committed Apr 20, 2024
1 parent 1531f0e commit 355b904
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base",
"schedule:weekends"
],
"prHourlyLimit": 8,
"packageRules": [
{
"paths": ["**"],
"groupName": "backend"
}
]
}
38 changes: 38 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy

on: push

jobs:

build-and-deploy:
name: build and deploy (main)
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker registry
uses: docker/login-action@v2
with:
registry: postmodern.alexdaniel.org
username: 'librervac'
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
push: true
tags: postmodern.alexdaniel.org/librervac-backend:${{ github.sha }} ${{ github.ref == 'refs/heads/main' && ', postmodern.alexdaniel.org/librervac-backend:latest' || '' }}
- name: Set SSH key
if: github.ref == 'refs/heads/main'
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Auth
if: github.ref == 'refs/heads/main'
run: ssh-keyscan -H postmodern.alexdaniel.org >> ~/.ssh/known_hosts
- name: Deploy
if: github.ref == 'refs/heads/main'
run: docker stack deploy --with-registry-auth -c compose.yaml librervac-backend
env:
DOCKER_HOST: ssh://[email protected]
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM httpd:2.4.58

RUN apt-get update
RUN apt-get install -y libcgi-pm-perl libcapture-tiny-perl libdatetime-perl libcapture-tiny-perl libgeo-ip-perl

COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf-extra
RUN cat /usr/local/apache2/conf/httpd.conf-extra >> /usr/local/apache2/conf/httpd.conf

COPY ./htdocs/ /usr/local/apache2/htdocs/
COPY ./cgi-bin/ /usr/local/apache2/cgi-bin/
COPY ./config/ /usr/local/apache2/config/

# Set permissions to www-data, there's seems to be no other way to do that
RUN sed -i 's/^exec /chown -R www-data:www-data \/srv\/data\n\nexec /' /usr/local/bin/httpd-foreground
27 changes: 27 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3.7"

services:
backend:
image: postmodern.alexdaniel.org/librervac-backend:latest
build:
context: .
volumes:
- /home/librervac/data/librervac/data:/srv/data
- /home/librervac/data/librervac/logs:/srv/logs
networks:
- caddy
deploy:
replicas: 1
update_config:
parallelism: 1
delay: 30s
order: start-first

labels:
caddy: librervac.org, www.librervac.org
caddy.tls: [email protected]
caddy.reverse_proxy: "{{upstreams 80}}"

networks:
caddy:
external: true
21 changes: 21 additions & 0 deletions httpd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
LoadModule cgid_module modules/mod_cgid.so
LoadModule rewrite_module modules/mod_rewrite.so

ServerAdmin [email protected]
DocumentRoot /usr/local/apache2/htdocs/

SetEnv WikiConfigFile /usr/local/apache2/config/config
SetEnv WikiModuleDir /usr/local/apache2/config/modules
SetEnv WikiDataDir /srv/data

<Directory />
Options -ExecCGI -FollowSymLinks -Indexes -Includes
AllowOverride None
</Directory>

<Directory /usr/local/apache2/htdocs/>
AllowOverride All
</Directory>

ErrorLog /srv/logs/error.log
CustomLog /srv/logs/access.log combined

0 comments on commit 355b904

Please sign in to comment.