Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강동현
/
nodejs-game
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
강동현
2021-06-10 18:04:20 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
8691a700af05b4b41c03c1b5c31858720f3e7117
8691a700
2 parents
6ac8ec1d
24e2f985
Builds for 1 pipeline
failed
in 1 minute 23 seconds
Merge branch 'feature/https' into develop
Changes
6
Builds
3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
3 deletions
docker-compose.yml
server/Dockerfile
server/Server.ts
web/Dockerfile
web/default.conf
web/src/contexts/SocketContext.ts
docker-compose.yml
View file @
8691a70
...
...
@@ -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
...
...
server/Dockerfile
View file @
8691a70
...
...
@@ -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
...
...
server/Server.ts
View file @
8691a70
import
express
from
"express"
;
import
socketIo
,
{
Server
as
IoServer
}
from
"socket.io"
;
import
{
createServer
}
from
"http"
;
import
{
createServer
}
from
"http
s
"
;
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
:
"*"
,
...
...
web/Dockerfile
View file @
8691a70
...
...
@@ -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;"]
...
...
web/default.conf
View file @
8691a70
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
;
...
...
web/src/contexts/SocketContext.ts
View file @
8691a70
import
React
from
"react"
;
import
{
io
}
from
"socket.io-client"
;
export
const
socket
=
io
(
`http://
${
window
.
location
.
hostname
}
:3000/`
);
export
const
socket
=
io
(
`http
s
://
${
window
.
location
.
hostname
}
:3000/`
);
const
SocketContext
=
React
.
createContext
(
socket
);
export
const
SocketProvider
=
SocketContext
.
Provider
;
...
...
Please
register
or
login
to post a comment