This commit is contained in:
Askill 2022-09-25 16:44:28 +02:00
commit 51488ba755
8 changed files with 38 additions and 5 deletions

5
.gitignore vendored
View File

@ -1,7 +1,6 @@
**/*.mod
**/*.sum
**/*.exe
**/*.exe
**/state.json
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

10
client/Dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM python:3.10
ENV TARGET=localhost:8080
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "clients.py" ]

View File

@ -89,6 +89,7 @@ async def sender(target, img):
return
except websockets.ConnectionClosed:
print("reconnecting")
continue
async def client(target):
@ -129,4 +130,9 @@ def asyncMain(x, target):
if __name__ == "__main__":
# with Pool(12) as p:
# print(p.map(asyncMain, [() for _ in range(12)]))
<<<<<<< HEAD
asyncMain(0, target=os.getenv("TARGET", "ws://venus:8080"))
=======
asyncMain(0, target="ws://" + os.getenv("TARGET", "venus:8080"))
>>>>>>> b385990c8446e128a68d99d65b2af4a7eb5b3bad

12
server/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM golang:1.19
WORKDIR /usr/src/app
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -v -o /usr/local/bin/app
CMD ["app"]

5
server/go.mod Normal file
View File

@ -0,0 +1,5 @@
module githb.com/askill/r_place
go 1.19
require github.com/gorilla/websocket v1.5.0

2
server/go.sum Normal file
View File

@ -0,0 +1,2 @@
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=

View File

@ -193,7 +193,7 @@ func saveState(img *image, path string, period time.Duration) {
}
func main() {
var addr = flag.String("addr", "localhost:8080", "http service address")
var addr = flag.String("addr", "0.0.0.0:8080", "http service address")
flag.Parse()
log.SetFlags(0)

File diff suppressed because one or more lines are too long