Skip to content

Commit

Permalink
Merge pull request #125 from Team-VoW/docker
Browse files Browse the repository at this point in the history
  • Loading branch information
kmaxii authored Aug 22, 2024
2 parents 1fb4cfa + 2752ade commit 61d05e8
Show file tree
Hide file tree
Showing 551 changed files with 1,413 additions and 1,205 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DB_ROOT_PASSWORD=rootpassword
DB_USER=vowuser
DB_PASSWORD=password
92 changes: 60 additions & 32 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,72 @@ on:
push:
branches:
- docker
- master

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
platforms: linux/arm64
load: true
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/vow-website:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Summarize the Docker digest
run: |
echo 'Digest: ${{ steps.build-docker.outputs.digest }}'
- name: Build Docker image
id: build
run: |
docker buildx build --platform linux/amd64 --push -t ${{ secrets.DOCKER_HUB_USERNAME }}/vow-website:latest .
- name: Copy docker-compose.yml to Oracle Cloud
run: |
echo "${{ secrets.ORACLE_CLOUD_SSH_PRIVATE_KEY }}" > oracle_cloud_key
chmod 600 oracle_cloud_key
scp -i oracle_cloud_key -o StrictHostKeyChecking=no docker-compose.yml ${{ secrets.ORACLE_CLOUD_SSH_USER }}@${{ secrets.ORACLE_CLOUD_IP }}:website/
rm oracle_cloud_key
- name: Deploy to Oracle Cloud
if: success()
env:
OCI_CLI_AUTH: instance_principal
DB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: |
ssh -i ${{ secrets.ORACLE_CLOUD_SSH_PRIVATE_KEY }} ${{ secrets.ORACLE_CLOUD_SSH_USER }}@${{ secrets.ORACLE_CLOUD_IP }} << EOF
cd /path/to/your/project
git pull origin master
docker compose down
export DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
export DB_USER=${DB_USER}
export DB_PASSWORD=${DB_PASSWORD}
docker compose pull
docker compose up -d
EOF
- name: Deploy to Oracle Cloud
env:
OCI_CLI_AUTH: instance_principal
DB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
run: |
echo "${{ secrets.ORACLE_CLOUD_SSH_PRIVATE_KEY }}" > oracle_cloud_key
chmod 600 oracle_cloud_key
ssh -i oracle_cloud_key -o StrictHostKeyChecking=no ${{ secrets.ORACLE_CLOUD_SSH_USER }}@${{ secrets.ORACLE_CLOUD_IP }} << EOF
cd website
docker compose down
echo "$DOCKER_HUB_ACCESS_TOKEN" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
export DB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
export DB_USER=${DB_USER}
export DB_PASSWORD=${DB_PASSWORD}
export DOCKER_IMAGE=${DOCKER_HUB_USERNAME}/vow-website:latest
export COMPOSE_FILE_DIR=/home/opc/website
docker compose pull
docker compose up -d
docker logout
EOF
rm oracle_cloud_key
145 changes: 72 additions & 73 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,73 +1,72 @@
Options -Indexes

RewriteEngine On

# In case of redirection problems, uncommenting the following line might help
# RewriteBase /

# In case it's necessary to allow direct access to all files besides those with extensions listed bellow, uncomment the next two lines
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUESt_URI} files/updater-data/.* [OR]
RewriteCond %{REQUEST_URI} files/core-dev-server/.*
RewriteRule ^.*$ - [NC,L]

RewriteCond %{REQUEST_URI} browserconfig\.xml$ [OR]
RewriteCond %{REQUEST_URI} site\.webmanifest$
RewriteRule ^.*$ - [NC,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.(css|js|txt|ico|ttf|xml|svg|gif|png|ogg|jpg)$ - [NC,L]

RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

# Use .phtml files as .php files
AddType application/x-httpd-php .php .phtml

# Compress HTML, CSS, JavaScript, Text, XML a fonts
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
</IfModule>

# Cache for one week (HTTP/1.0)
#<IfModule mod_expires.c>
# ExpiresActive On
# ExpiresDefault "access plus 1 seconds"
# ExpiresByType text/css "access plus 604800 seconds"
# ExpiresByType text/javascript "access plus 604800 seconds"
# ExpiresByType image/png "access plus 604800 seconds"
# ExpiresByType image/gif "access plus 604800 seconds"
# ExpiresByType image/x-icon "access plus 604800 seconds"
# ExpiresByType image/svg+xml "access plus 604800 seconds"
#</IfModule>

# Cache for one week (HTTP/1.1)
#<IfModule mod_headers.c>
# <filesMatch ".(css|js|png|gif|ico|svg)$">
# Header set Cache-Control "max-age=604800, public"
# </filesMatch>
#</IfModule>
Options -Indexes

RewriteEngine On

# In case of redirection problems, uncommenting the following line might help
# RewriteBase /

# In case it's necessary to allow direct access to all files besides those with extensions listed bellow, uncomment the next two lines
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUESt_URI} files/updater-data/.*
RewriteRule ^.*$ - [NC,L]

RewriteCond %{REQUEST_URI} browserconfig\.xml$ [OR]
RewriteCond %{REQUEST_URI} site\.webmanifest$
RewriteRule ^.*$ - [NC,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.(css|js|txt|ico|ttf|xml|svg|gif|png|ogg|jpg)$ - [NC,L]

RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

# Use .phtml files as .php files
AddType application/x-httpd-php .php .phtml

# Compress HTML, CSS, JavaScript, Text, XML a fonts
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
</IfModule>

# Cache for one week (HTTP/1.0)
#<IfModule mod_expires.c>
# ExpiresActive On
# ExpiresDefault "access plus 1 seconds"
# ExpiresByType text/css "access plus 604800 seconds"
# ExpiresByType text/javascript "access plus 604800 seconds"
# ExpiresByType image/png "access plus 604800 seconds"
# ExpiresByType image/gif "access plus 604800 seconds"
# ExpiresByType image/x-icon "access plus 604800 seconds"
# ExpiresByType image/svg+xml "access plus 604800 seconds"
#</IfModule>

# Cache for one week (HTTP/1.1)
#<IfModule mod_headers.c>
# <filesMatch ".(css|js|png|gif|ico|svg)$">
# Header set Cache-Control "max-age=604800, public"
# </filesMatch>
#</IfModule>
104 changes: 52 additions & 52 deletions Controllers/Api/ApiController.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
<?php

namespace VoicesOfWynn\Controllers\Api;

use VoicesOfWynn\Controllers\Controller;

/**
* Base class for all API controllers
*/
abstract class ApiController extends Controller
{

/* All API keys go here */
//Line reporting keys
const COLLECTING_API_KEY = 'testing';
const UPDATING_API_KEY = 'testing';
//Usage analysis api keys
const AGGREGATE_API_KEY = 'testing';
//Discord integration key
const DISCORD_INTEGRATION_API_KEY = 'testing';
//Premium authenticator key
const PREMIUM_AUTHENTICATOR_API_KEY = 'testing';

/**
* Controller constructor enabling output buffering and setting the Content-Type header
* Since specific controllers don't have a constructor, this will be invoked every time a new constructor is
* instantiated
*/
public function __construct()
{
header('Content-Type: application/json');

//Start output buffering and keep it enabled for the whole duration of processing the request.
//Output is harvested and returned in the getOutput() method
ob_start();
}

/**
* @inheritDoc
*/
public abstract function process(array $args): int;

/**
* Method returning the final response of this API request
* This is called from the RouterController
* @return string Final response to send to the client
*/
public function getOutput() {
$result = ob_get_contents();
ob_end_clean();
return $result;
}
<?php

namespace VoicesOfWynn\Controllers\Api;

use VoicesOfWynn\Controllers\Controller;

/**
* Base class for all API controllers
*/
abstract class ApiController extends Controller
{

/* All API keys go here */
//Line reporting keys
const COLLECTING_API_KEY = 'testing';
const UPDATING_API_KEY = 'testing';
//Usage analysis api keys
const AGGREGATE_API_KEY = 'testing';
//Discord integration key
const DISCORD_INTEGRATION_API_KEY = 'testing';
//Premium authenticator key
const PREMIUM_AUTHENTICATOR_API_KEY = 'testing';

/**
* Controller constructor enabling output buffering and setting the Content-Type header
* Since specific controllers don't have a constructor, this will be invoked every time a new constructor is
* instantiated
*/
public function __construct()
{
header('Content-Type: application/json');

//Start output buffering and keep it enabled for the whole duration of processing the request.
//Output is harvested and returned in the getOutput() method
ob_start();
}

/**
* @inheritDoc
*/
public abstract function process(array $args): int;

/**
* Method returning the final response of this API request
* This is called from the RouterController
* @return string Final response to send to the client
*/
public function getOutput() {
$result = ob_get_contents();
ob_end_clean();
return $result;
}
}
Loading

0 comments on commit 61d05e8

Please sign in to comment.