Skip to content

Commit 81d7cf4

Browse files
Add docker file
1 parent fc0fdac commit 81d7cf4

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

apps/matching-service/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Stage 1: Build Go Application
2+
3+
FROM golang:1.23 AS builder
4+
5+
WORKDIR /usr/src/app
6+
7+
COPY go.mod go.sum ./
8+
9+
RUN go mod tidy && go mod download && go mod verify
10+
11+
# Copy the .env file to the final image
12+
COPY .env /usr/src/app/.env
13+
14+
COPY . .
15+
16+
RUN go build -v -o /usr/local/bin/app ./main.go
17+
18+
# Stage 2: Setup Redis and combine with Go
19+
FROM redis:latest
20+
21+
# Copy the built Go binary from the builder stage
22+
COPY --from=builder /usr/local/bin/app /usr/local/bin/app
23+
24+
EXPOSE 8081 6379
25+
26+
# Start both Redis and the Go application
27+
CMD ["sh", "-c", "redis-server & app; wait"]

apps/matching-service/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ Make sure to open the HTML file in a web browser while the WebSocket server is r
121121

122122
You can open one instance of the HTML file in multiple tabs to simulate multiple clients connecting to the server. (In the future: ensure that only one connection is allowed per user)
123123

124-
## Docker Support
124+
## Running the Application via Docker
125125

126-
TODO: Add section for Docker setup and usage instructions.
126+
To run the application via Docker, run the following command:
127+
128+
```bash
129+
docker build -t matching-service .
130+
```
131+
132+
```bash
133+
docker run -d -p 8081:8081 -p 6379:6379 --name matching-service-container matching-service
134+
```

0 commit comments

Comments
 (0)