Dockerize websocket server

This commit is contained in:
Zoe Roux 2024-03-15 23:10:47 +01:00
parent 61ee5e53fb
commit 344941057d
No known key found for this signature in database
5 changed files with 36 additions and 0 deletions

View File

@ -118,6 +118,21 @@ services:
env_file: env_file:
- ./.env - ./.env
websockets:
build:
context: ./websockets
dockerfile: Dockerfile.dev
volumes:
- ./websockets:/app
restart: on-failure
depends_on:
- rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
ports:
- 7777:7777
transcoder: transcoder:
<<: *transcoder-base <<: *transcoder-base
profiles: ['', 'cpu'] profiles: ['', 'cpu']

View File

@ -36,6 +36,7 @@ in
postgresql_15 postgresql_15
pgformatter pgformatter
biome biome
websocat
]; ];
DOTNET_ROOT = "${dotnet}"; DOTNET_ROOT = "${dotnet}";

13
websockets/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM golang:1.21-alpine as build
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o ./websockets
FROM alpine
WORKDIR /app
COPY --from=build /app/websockets /app/websockets
EXPOSE 7777
CMD ./websockets

View File

@ -0,0 +1,6 @@
FROM golang:1.21-alpine
RUN go install github.com/bokwoon95/wgo@latest
WORKDIR /app
EXPOSE 7777
CMD wgo run .

View File

@ -38,6 +38,7 @@ func main() {
} }
}) })
log.Println("Listening on :7777")
err := http.ListenAndServe(":7777", nil) err := http.ListenAndServe(":7777", nil)
log.Fatal(err) log.Fatal(err)
} }