Skip to content

Commit f425d22

Browse files
committed
Add: Update docker file to deploy app
1 parent af74b71 commit f425d22

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.git*
22

3-
README.md
3+
README.md
4+
data

Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From golang:1.22-alpine AS builder
1+
FROM golang:tip-alpine3.22 AS builder
22

33
WORKDIR /app
44

@@ -8,15 +8,19 @@ RUN go mod download
88

99
COPY . .
1010

11-
RUN go build -o cmd/api/main.go
11+
RUN go build -o app ./cmd/api
1212

1313
FROM alpine:latest
1414

15-
COPY --from=builder /app/main .
15+
WORKDIR /app
16+
17+
COPY --from=builder /app/app .
18+
COPY .env .
19+
1620

1721
EXPOSE 8080
1822

19-
CMD [ "app/main" ]
23+
CMD ["sh", "-c", "./app" ]
2024

2125

2226

File renamed without changes.

docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
app:
3+
build: .
4+
ports:
5+
- 8080:8080
6+
env_file:
7+
- .env
8+
depends_on:
9+
- db
10+
healthcheck:
11+
test: echo 'db.runCommand("ping").ok' | mongosh db:27017/players --quiet
12+
restart: unless-stopped
13+
networks:
14+
- app-players
15+
db:
16+
image: mongo
17+
ports:
18+
- "27017:27017"
19+
environment:
20+
MONGO_INITDB_ROOT_USERNAME: root
21+
MONGO_INITDB_ROOT_PASSWORD: password
22+
volumes:
23+
- mongo_data:/data/db
24+
restart: unless-stopped
25+
networks:
26+
- app-players
27+
28+
volumes:
29+
mongo_data:
30+
networks:
31+
app-players:

0 commit comments

Comments
 (0)