Skip to content

Commit ddf10be

Browse files
committed
Add deployement scripts
Signed-off-by: kiranpranay <pranay@cottonseeds.org>
1 parent 0650f4a commit ddf10be

File tree

5 files changed

+114
-61
lines changed

5 files changed

+114
-61
lines changed

.github/workflows/deploy.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy stmorg.weberq.in
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Deploy to VPS
15+
uses: appleboy/ssh-action@v1.0.0
16+
with:
17+
host: ${{ secrets.VPS_HOST }} # Your Server IP
18+
username: ${{ secrets.VPS_USER }} # weberqbot
19+
key: ${{ secrets.VPS_SSH_KEY }} # Server Private Key
20+
script: |
21+
# --- Configuration ---
22+
APP_NAME="stmorg.weberq.in"
23+
REPO_URL="git@github.com:${{ github.repository }}.git"
24+
PROJECT_DIR="/home/weberqbot/apps/$APP_NAME"
25+
# ---------------------
26+
27+
echo "🚀 Deploying $APP_NAME..."
28+
29+
# 1. Ensure apps directory exists
30+
mkdir -p /home/weberqbot/apps
31+
32+
# 2. Clone or Pull
33+
if [ -d "$PROJECT_DIR" ]; then
34+
echo "📂 App directory exists. Pulling latest changes..."
35+
cd "$PROJECT_DIR"
36+
git pull origin main
37+
else
38+
echo "✨ Cloning repository..."
39+
git clone "$REPO_URL" "$PROJECT_DIR"
40+
cd "$PROJECT_DIR"
41+
fi
42+
43+
# 3. Build and Start
44+
echo "🐳 Rebuilding Container..."
45+
# Force recreate to ensure new builds are picked up
46+
docker compose down --remove-orphans || true
47+
docker compose up -d --build
48+
49+
echo "✅ Deployment of $APP_NAME Complete!"
50+

.github/workflows/main.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

Dockerfile

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,55 @@
1-
# Use official PHP image with Apache
2-
FROM php:8.2-apache
1+
# -----------------------------------------------------------
2+
# Robust PHP Dockerfile Template
3+
# Generated by WeberQ Infrastructure Scaffolding
4+
# -----------------------------------------------------------
35

4-
# Install required PHP extensions
5-
RUN docker-php-ext-install mysqli pdo pdo_mysql
6+
FROM php:8.2-apache
67

7-
# Enable mod_rewrite for Apache
8+
# 1. Install System Dependencies (for GD, Zip, etc.)
9+
RUN apt-get update && apt-get install -y \
10+
libpng-dev \
11+
libjpeg-dev \
12+
libfreetype6-dev \
13+
libzip-dev \
14+
libicu-dev \
15+
libonig-dev \
16+
curl \
17+
unzip \
18+
git \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# 2. Configure PHP Extensions
22+
# GD: Configure for JPEG/FreeType support
23+
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
24+
25+
# Install standard extensions
26+
RUN docker-php-ext-install \
27+
pdo_mysql \
28+
mysqli \
29+
gd \
30+
zip \
31+
bcmath \
32+
intl \
33+
opcache
34+
35+
# 3. Enable Apache mod_rewrite (Crucial for modern frameworks)
836
RUN a2enmod rewrite
937

10-
# Set working directory
38+
# 4. Set working directory
1139
WORKDIR /var/www/html
1240

13-
# Copy application files
41+
# 5. Copy Application Source
1442
COPY . /var/www/html
1543

16-
# Set correct permissions
44+
# 6. Permissions (Ensure Apache can read/write)
1745
RUN chown -R www-data:www-data /var/www/html \
1846
&& chmod -R 755 /var/www/html
1947

20-
# Expose port 80
21-
EXPOSE 80
48+
# 7. Use Default Production Configuration
49+
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
2250

23-
# Start Apache
24-
CMD ["apache2-foreground"]
51+
# (Optional) Increase upload limits - Uncomment if needed
52+
# RUN echo "upload_max_filesize = 64M" > /usr/local/etc/php/conf.d/uploads.ini
53+
# RUN echo "post_max_size = 64M" >> /usr/local/etc/php/conf.d/uploads.ini
2554

55+
EXPOSE 80

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '3'
2+
3+
services:
4+
web:
5+
build: .
6+
container_name: stmorg.weberq.in_app
7+
restart: always
8+
labels:
9+
- "traefik.enable=true"
10+
# Router Config
11+
- "traefik.http.routers.stmorg.weberq.in.rule=Host(`stmorg.weberq.in`)"
12+
- "traefik.http.routers.stmorg.weberq.in.entrypoints=web"
13+
# Load Balancer Config (Port 80 is standard for our PHP image)
14+
- "traefik.http.services.stmorg.weberq.in.loadbalancer.server.port=80"
15+
networks:
16+
- web_network
17+
18+
networks:
19+
web_network:
20+
external: true
21+

infra-config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit bf79259061cdd5a20c0f91eb0f88af169639f2ce

0 commit comments

Comments
 (0)