Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Deploy WordPress on HuggingFace
Browse files Browse the repository at this point in the history
  • Loading branch information
belajarqywok committed Sep 26, 2024
0 parents commit f5afb68
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/pipelines.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: pipeline

on:
push:
branches:
- main
tags:
- '*'

jobs:

wordpress_deployment:
name: Wordpress Deployment
runs-on: ubuntu-latest
environment: Production

env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
SPACE_NAME: wp-nginx-test
HF_USERNAME: qywok

steps:
- name: Set global directory
run: git config --global --add safe.directory /github/workspace

- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 1000

- name: Check git status
run: git status

- name: Configure git
run: |
git config --local user.email "alfariqyraihan@gmail.com"
git config --local user.name "qywok"
- name: Pull changes from remote
run: |
git pull https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main || \
(git merge --strategy-option theirs)
- name: Add and commit changes
run: |
git add -A
git diff-index --quiet HEAD || git commit -m "Wordpress Deployment"
- name: Push to Hugging Face
run: |
git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main --force
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
credentials
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM php:7.4-fpm-alpine

RUN apk --no-cache add nginx

RUN mkdir -p /var/log/nginx /var/tmp/nginx /run/nginx

RUN chown -R nginx:nginx /var/log/nginx /var/tmp/nginx /run/nginx && \
chmod -R 755 /var/log/nginx /var/tmp/nginx /run/nginx

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

COPY start.sh /start.sh
RUN chmod +x /start.sh

RUN mkdir -p /var/www/html && echo "<?php phpinfo(); ?>" > /var/www/html/index.php

EXPOSE 7860

CMD ["/start.sh"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: WordPress Testing
emoji: 🌐
colorFrom: purple
colorTo: blue
sdk: docker
pinned: false
---
35 changes: 35 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;

server {
listen 7860;
server_name localhost;

root /var/www/html;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
}
6 changes: 6 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

php-fpm &

exec nginx -g 'daemon off;'

0 comments on commit f5afb68

Please sign in to comment.