Skip to content

Commit

Permalink
[add] Azure Blob configuration & GitHub Actions badge
Browse files Browse the repository at this point in the history
[optimize] update Meta Data
  • Loading branch information
TechQuery committed Nov 21, 2023
1 parent c503b3d commit b7a2043
Show file tree
Hide file tree
Showing 9 changed files with 592 additions and 107 deletions.
17 changes: 9 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
HOST=0.0.0.0
PORT=1337
APP_KEYS="toBeModified1,toBeModified2"
API_TOKEN_SALT=tobemodified
ADMIN_JWT_SECRET=tobemodified
TRANSFER_TOKEN_SALT=tobemodified
JWT_SECRET=tobemodified
DATABASE_URL=postgres://user:password@host:port/database
APP_KEYS = "toBeModified1,toBeModified2"
API_TOKEN_SALT = tobemodified
TRANSFER_TOKEN_SALT = tobemodified
JWT_SECRET = tobemodified
ADMIN_JWT_SECRET = tobemodified

DATABASE_URL = postgres://user:password@host:port/database
AZURE_BLOB_BASE_URL = https://your-account.core.chinacloudapi.cn
AZURE_BLOB_CONNECTION = "DefaultEndpointsProtocol=https;AccountName=your-account;AccountKey=your-account-key;EndpointSuffix=core.chinacloudapi.cn"
6 changes: 3 additions & 3 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
ARTIFACT_PATH: artifact.tar
BOX_NAME: strapi-server
BOX_URL: idea2app/strapi-server
BOX_URL: ohp/strapi-server

jobs:
deploy_docker_image:
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Pick Docker Compose
run: |
mkdir ./build
mv ${{ env.ARTIFACT_PATH }} ./docker-compose.yml ./start.sh ./build
mv ${{ env.ARTIFACT_PATH }} .env ./docker-compose.yml ./start.sh ./build
- name: Transport Image
uses: garygrossgarten/github-action-scp@release
Expand All @@ -61,7 +61,7 @@ jobs:
command: |
cd /tmp/${{ env.BOX_NAME }}
mkdir -p ~/${{ env.BOX_NAME }}
mv docker-compose.yml start.sh ~/${{ env.BOX_NAME }}
mv .env docker-compose.yml start.sh ~/${{ env.BOX_NAME }}
cd ~/${{ env.BOX_NAME }}
chmod +x start.sh
echo '${{ secrets.SSH_KEY }}' | sudo -S ./start.sh /tmp/${{ env.BOX_NAME }}/${{ env.ARTIFACT_PATH }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ $RECYCLE.BIN/

*#
ssl
.vscode/settings.json
.idea
nbproject
public/uploads/*
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Strapi scaffold with TypeScript, PNPM & Docker
# Open Hackathon Platform - Web server

Strapi comes with a full featured [Command Line Interface][1] (CLI) which lets you scaffold and manage your project in seconds.
Open Hackathon Platform server v5 based on [Strapi][6]

[![Deploy to Production environment](https://github.com/kaiyuanshe/OpenHackathon-server/actions/workflows/deploy-production.yml/badge.svg)][1]

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)][2]
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)][3]
Expand Down Expand Up @@ -97,9 +99,9 @@ Feel free to check out the [Strapi GitHub repository][27]. Your feedback and con

🤫 Psst! [Strapi is hiring][31].

[1]: https://docs.strapi.io/dev-docs/cli
[2]: https://codespaces.new/idea2app/Strapi-PNPM-Docker-ts
[3]: https://gitpod.io/?autostart=true#https://github.com/idea2app/Strapi-PNPM-Docker-ts
[1]: https://github.com/kaiyuanshe/OpenHackathon-server/actions/workflows/deploy-production.yml
[2]: https://codespaces.new/kaiyuanshe/OpenHackathon-server
[3]: https://gitpod.io/?autostart=true#https://github.com/kaiyuanshe/OpenHackathon-server
[4]: https://www.typescriptlang.org/
[5]: https://pnpm.io/
[6]: https://strapi.io/
Expand Down
17 changes: 15 additions & 2 deletions config/middlewares.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
export default [
export default ({ env }) => [
'strapi::errors',
'strapi::security',
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'connect-src': ["'self'", 'https:'],
'img-src': ["'self'", 'data:', 'blob:', env('AZURE_BLOB_BASE_URL')],
'media-src': ["'self'", 'data:', 'blob:', env('AZURE_BLOB_BASE_URL')],
upgradeInsecureRequests: null,
},
},
},
},
'strapi::cors',
'strapi::poweredBy',
'strapi::logger',
Expand Down
10 changes: 9 additions & 1 deletion config/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default () => ({
export default ({ env }) => ({
transformer: {
enabled: true,
responseTransforms: {
Expand All @@ -7,4 +7,12 @@ export default () => ({
},
},
'react-icons': true,
upload: {
provider: '@ntegral/strapi-provider-upload-azure-storage-blob',
providerOptions: {
connectionString: env('AZURE_BLOB_CONNECTION'),
containerName: '$web',
defaultPath: 'assets',
},
},
});
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ services:
volumes:
- ./data:/var/lib/postgresql/data/
ports:
- 5432:5432
- 5433:5432
restart: always

strapi-server:
depends_on:
- postgres-server
image: idea2app/strapi-server
image: ohp/strapi-server
environment:
- DATABASE_URL=postgres://postgres:${ADMIN_JWT_SECRET}@postgres-server:5432/postgres
- DATABASE_URL=postgres://postgres:${ADMIN_JWT_SECRET}@postgres-server:5433/postgres
- NODE_ENV=production
- PORT=1337
ports:
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "strapi-pnpm-docker-ts",
"name": "@ohp/web-server",
"version": "0.4.0",
"private": true,
"engines": {
Expand All @@ -8,6 +8,7 @@
},
"dependencies": {
"@ckeditor/strapi-plugin-ckeditor": "^0.0.10",
"@ntegral/strapi-provider-upload-azure-storage-blob": "^2.0.8",
"@strapi/plugin-color-picker": "^4.15.4",
"@strapi/plugin-documentation": "4.15.4",
"@strapi/plugin-i18n": "4.15.4",
Expand All @@ -30,6 +31,7 @@
"@codemirror/search": "^6.5.4",
"@codemirror/theme-one-dark": "^6.1.2",
"cross-env": "^7.0.3",
"get-git-folder": "^0.1.2",
"husky": "^8.0.3",
"lint-staged": "^15.1.0",
"prettier": "^3.1.0"
Expand All @@ -41,7 +43,8 @@
"*.{md,json,yml,js,mjs,ts,tsx}": "prettier --write"
},
"scripts": {
"prepare": "husky install",
"prepare": "husky install || true",
"install": "get-git-folder https://github.com/kaiyuanshe/service-configuration main OpenHackathon-server || true",
"test": "lint-staged",
"strapi": "strapi",
"clean": "rm -rf .cache/ .strapi/ dist/",
Expand Down
Loading

0 comments on commit b7a2043

Please sign in to comment.