From 45f6ac02c04a7742baacc4e40396af40e1223a3f Mon Sep 17 00:00:00 2001 From: Viral Parmar Date: Tue, 26 Sep 2023 20:47:42 +0530 Subject: [PATCH] Add docker support --- Dockerfile | 12 ++++++++++++ Makefile | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dbbcaad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:1.21-alpine3.18 AS builder +WORKDIR /app +COPY . . +RUN go build -o main main.go + +FROM alpine:3.13 +WORKDIR /app +COPY --from=builder /app/main . +COPY app.env . +EXPOSE 8080 + +CMD ["/app/main"] \ No newline at end of file diff --git a/Makefile b/Makefile index 3d2c434..9a4c2ed 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ postgres: - docker run --name postgres12 -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret -d postgres:12-alpine + docker run --name postgres12 --network bank-net -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret -d postgres:12-alpine createdb: docker exec -it postgres12 createdb --username=root --owner=root simple_bank