강동현
Builds for 1 pipeline failed in 1 minute 23 seconds

Merge branch 'feature/https' into develop

......@@ -8,6 +8,8 @@ services:
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- /etc/letsencrypt:/etc/letsencrypt
web:
build:
......@@ -15,4 +17,7 @@ services:
dockerfile: ./web/Dockerfile
restart: unless-stopped
ports:
- "443:443"
- "80:80"
volumes:
- /etc/letsencrypt:/etc/letsencrypt
......
......@@ -11,6 +11,8 @@ RUN yarn install
WORKDIR /usr/server
RUN apk add --no-cache build-base gcc python3
RUN yarn install
RUN yarn build
......
import express from "express";
import socketIo, { Server as IoServer } from "socket.io";
import { createServer } from "http";
import { createServer } from "https";
import { RoomManager } from "./room/RoomManager";
import { Connection } from "./connection/Connection";
import { SocketIoWrapper } from "./connection/SocketWrapper";
import { readFileSync } from "fs";
export class Server {
public readonly port: number;
......@@ -13,7 +14,20 @@ export class Server {
this.port = port;
const app = express();
const server = createServer(app);
const server = createServer(
{
cert: readFileSync(
"/etc/letsencrypt/live/2020105578.oss2021.tk/cert.pem"
),
key: readFileSync(
"/etc/letsencrypt/live/2020105578.oss2021.tk/privkey.pem"
),
ca: readFileSync(
"/etc/letsencrypt/live/2020105578.oss2021.tk/fullchain.pem"
),
},
app
);
this.io = new socketIo.Server(server, {
cors: {
origin: "*",
......
......@@ -19,6 +19,7 @@ FROM nginx:latest
COPY web/default.conf /etc/nginx/conf.d/default.conf
COPY --from=build /usr/web/build /usr/web/build
EXPOSE 443
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
......
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl default_server;
server_name 2020105578.oss2021.tk;
ssl_certificate /etc/letsencrypt/live/2020105578.oss2021.tk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/2020105578.oss2021.tk/privkey.pem;
location / {
root /usr/web/build;
index index.html;
......
import React from "react";
import { io } from "socket.io-client";
export const socket = io(`http://${window.location.hostname}:3000/`);
export const socket = io(`https://${window.location.hostname}:3000/`);
const SocketContext = React.createContext(socket);
export const SocketProvider = SocketContext.Provider;
......