Skip to content

Commit 2f1f68a

Browse files
committed
dockerization
1 parent 2602505 commit 2f1f68a

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

.env

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BACKEND_ADDRESS=0.0.0.0:8080
2+
DATABASE_URL=postgresql://admin:admin@database:5432/db_go-backend-demo
3+
JWTSECRET=jXn2r5u8x/A?D*G-KaPdSgVkYp3s6v9y
4+
5+
POSTGRES_USER=admin
6+
POSTGRES_PASSWORD=admin
7+
POSTGRES_DB=db_go-backend-demo

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To make sure our syntax is up-to-date
2+
# syntax=docker/dockerfile:1
3+
4+
FROM golang:1.17.8-alpine3.15
5+
6+
WORKDIR /usr/src/go-backend-demo
7+
COPY go.mod go.sum ./
8+
RUN go mod download && go mod verify
9+
10+
COPY . .
11+
RUN go build -v -o /usr/local/bin/go-backend-demo .
12+
13+
EXPOSE 8080
14+
15+
CMD ["go-backend-demo"]

docker-compose.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: "3.8"
2+
services:
3+
database:
4+
image: postgres:latest
5+
container_name: go-backend-db
6+
restart: always
7+
env_file:
8+
- .env
9+
ports:
10+
- "5433:5433"
11+
volumes:
12+
- dbdata:/var/lib/postgres/data/
13+
server:
14+
container_name: go-backend-demo
15+
build:
16+
context: .
17+
env_file:
18+
- .env
19+
networks:
20+
- default # default bridge network
21+
ports:
22+
- "8080:8080"
23+
depends_on:
24+
- database
25+
volumes:
26+
dbdata:
27+

0 commit comments

Comments
 (0)