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 22, 2023
1 parent c503b3d commit 43138d0
Show file tree
Hide file tree
Showing 9 changed files with 557 additions and 170 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
35 changes: 26 additions & 9 deletions config/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
export default () => ({
transformer: {
enabled: true,
responseTransforms: {
removeDataKey: true,
removeAttributesKey: true,
export default ({ env }) => {
const serviceBaseURL = env('AZURE_BLOB_BASE_URL');
const [_, account] = serviceBaseURL.split(/\W+/);

return {
transformer: {
enabled: true,
responseTransforms: {
removeDataKey: true,
removeAttributesKey: true,
},
},
},
'react-icons': true,
});
'react-icons': true,
upload: {
config: {
provider: 'strapi-provider-upload-azure-storage',
providerOptions: {
serviceBaseURL,
account,
accountKey: env('AZURE_BLOB_ACCOUNT_KEY'),
containerName: '$web',
defaultPath: 'assets',
},
},
},
};
};
11 changes: 7 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
version: '3'

volumes:
ohp-database:

services:
postgres-server:
image: postgres
environment:
- POSTGRES_PASSWORD=${ADMIN_JWT_SECRET}
volumes:
- ./data:/var/lib/postgresql/data/
- ohp-database:/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 @@ -22,6 +22,7 @@
"strapi-plugin-multi-select": "^1.2.2",
"strapi-plugin-react-icons": "^0.2.1",
"strapi-plugin-transformer": "^3.1.2",
"strapi-provider-upload-azure-storage": "^3.3.0",
"styled-components": "^5.3.11"
},
"devDependencies": {
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 43138d0

Please sign in to comment.