Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /home/node/app

# Install Dependencies
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --no-cache
RUN yarn config set registry https://registry.npmmirror.com && yarn install --frozen-lockfile --no-cache

# Copy source code
COPY . .
Expand All @@ -20,7 +20,7 @@ ENV NODE_ENV=production

# Install Production Dependencies
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --no-cache --production
RUN yarn config set registry https://registry.npmmirror.com && yarn install --frozen-lockfile --no-cache --production

# Copy build files
COPY --from=builder /home/node/app/build ./build
Expand Down
5 changes: 3 additions & 2 deletions backend/src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const limits = {
const storage = multer.diskStorage({
destination: (req, file, cb) => {
try {
const room = req.params.room;
const room = req.params.room as string;
const dir = path.resolve(baseDir, room);
fs.mkdirSync(dir, { recursive: true });
return cb(null, dir);
Expand All @@ -29,7 +29,8 @@ const storage = multer.diskStorage({
})
const upload = multer({ storage, limits });

router.post("/upload/:room", authenticate, upload.single("file"), (req, res) => {
const uploadSingle = upload.single("file") as unknown as express.RequestHandler;
router.post("/upload/:room", authenticate, uploadSingle, (req, res) => {
const file = req.file;
if (!file) {
return res.status(422).send("422 Unprocessable Entity: Missing file");
Expand Down
15 changes: 15 additions & 0 deletions server/backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
backend:
image: backend:latest
restart: always
ports:
- 20248:8888
env_file:
- .local.env
volumes:
- /data/upload:/data/upload

networks:
default:
name: database_default
external: true
15 changes: 14 additions & 1 deletion server/nginx/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@ services:
nginx:
image: nginx:stable-alpine
ports:
- 443:443
- "80:80"
- "443:443"
restart: always
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- /etc/letsencrypt:/etc/letsencrypt
networks:
- backend
- database

networks:
backend:
name: backend_default
external: true
database:
name: database_default
external: true

35 changes: 35 additions & 0 deletions server/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
events {
worker_connections 1024;
}

http {
server {
listen 80; # HTTP -> HTTPS redirect
listen [::]:80;
server_name zijingmoments.xyz;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl; # listen to IPv4, with SSL
listen [::]:443 ssl; # listen to IPv6, with SSL

server_name zijingmoments.xyz;

ssl_certificate /etc/letsencrypt/live/zijingmoments.xyz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/zijingmoments.xyz/privkey.pem;

location / {
proxy_pass http://backend:8888;
proxy_set_header Host $host;
client_max_body_size 100M; # allow large file upload
}

location /v1/graphql {
proxy_pass http://graphql-engine:8080;
# Important: Do not add / to the end of URL, ref: https://blog.csdn.net/q1298252589/article/details/120729989
proxy_set_header Upgrade $http_upgrade; # enable websocket
proxy_set_header Connection "upgrade"; # enable websocket
}
}
}