From fffcb0fb2a3e84a2dc5f64a1ca64f4f0c4229bb3 Mon Sep 17 00:00:00 2001 From: Pratham Date: Sun, 7 Aug 2022 16:35:56 +0530 Subject: [PATCH 1/8] add files for dockerizing --- .dockerignore | 23 +++++++++++++++++++++++ .gitignore | 0 .golangci.yml | 0 Dockerfile | 13 +++++++++++++ LICENSE | 0 Makefile | 0 README.md | 0 api/main.go | 0 cmd/nymeria/main.go | 0 docker-compose.yaml | 12 ++++++++++++ go.mod | 0 go.sum | 0 pkg/.gitkeep | 0 13 files changed, 48 insertions(+) create mode 100644 .dockerignore mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .golangci.yml create mode 100644 Dockerfile mode change 100644 => 100755 LICENSE mode change 100644 => 100755 Makefile mode change 100644 => 100755 README.md mode change 100644 => 100755 api/main.go mode change 100644 => 100755 cmd/nymeria/main.go create mode 100644 docker-compose.yaml mode change 100644 => 100755 go.mod mode change 100644 => 100755 go.sum mode change 100644 => 100755 pkg/.gitkeep diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6ae93fa --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +vendor/ +v1.46.2/ + +# Exclude the binary +nymeria +!nymeria/ + +# miscellaneous +.vscode/ diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.golangci.yml b/.golangci.yml old mode 100644 new mode 100755 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e2ef50a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM golang:1.17-alpine + +WORKDIR /usr/app + +COPY . /usr/app/ + +RUN apk add --update make + +RUN make vendor + +RUN make build + +RUN make run \ No newline at end of file diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/api/main.go b/api/main.go old mode 100644 new mode 100755 diff --git a/cmd/nymeria/main.go b/cmd/nymeria/main.go old mode 100644 new mode 100755 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..a2003be --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,12 @@ +version: "3.8" + +services: + app: + container_name: nymeria + build: + context: ./ + dockerfile: Dockerfile + args: + buildno: 1 + ports: + - "8080:8080" \ No newline at end of file diff --git a/go.mod b/go.mod old mode 100644 new mode 100755 diff --git a/go.sum b/go.sum old mode 100644 new mode 100755 diff --git a/pkg/.gitkeep b/pkg/.gitkeep old mode 100644 new mode 100755 From aa098fdee3157b0b2e4fc4424dbdbee934dde631 Mon Sep 17 00:00:00 2001 From: Pratham Date: Tue, 9 Aug 2022 10:10:44 +0530 Subject: [PATCH 2/8] dockerize golang server --- Dockerfile | 4 +++- docker-compose.yaml | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e2ef50a..41e3762 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,4 +10,6 @@ RUN make vendor RUN make build -RUN make run \ No newline at end of file +EXPOSE 8080 + +CMD ["make","run"] diff --git a/docker-compose.yaml b/docker-compose.yaml index a2003be..400860c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,5 +8,7 @@ services: dockerfile: Dockerfile args: buildno: 1 + extra_hosts: + - "localhost:127.0.0.1" ports: - "8080:8080" \ No newline at end of file From a5a430b14457657b5e66cb03a519e70c4d8aa34c Mon Sep 17 00:00:00 2001 From: Pratham Date: Sun, 14 Aug 2022 18:13:20 +0530 Subject: [PATCH 3/8] update README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 6cc742a..f8b6536 100755 --- a/README.md +++ b/README.md @@ -52,3 +52,9 @@ Add new packages to the repository using the command ```sh go get -u ``` + +To run nymeria using docker, run the following command + +```sh + docker-compose up --build -d +``` \ No newline at end of file From e23b784044dd1400f1393d4a9c04bfbb26368228 Mon Sep 17 00:00:00 2001 From: Pratham Date: Sun, 14 Aug 2022 18:21:19 +0530 Subject: [PATCH 4/8] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8b6536..a631c4a 100755 --- a/README.md +++ b/README.md @@ -56,5 +56,5 @@ Add new packages to the repository using the command To run nymeria using docker, run the following command ```sh - docker-compose up --build -d + docker-compose up --build -d ``` \ No newline at end of file From d63bd9e7bc2c4706fbca852a14a326e56be25be0 Mon Sep 17 00:00:00 2001 From: Pratham Date: Sun, 28 Aug 2022 13:54:52 +0530 Subject: [PATCH 5/8] update docker-compose file for postgres db --- docker-compose.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 400860c..04d3838 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,14 +1,24 @@ version: "3.8" services: - app: + server: container_name: nymeria build: context: ./ dockerfile: Dockerfile - args: - buildno: 1 extra_hosts: - "localhost:127.0.0.1" ports: - - "8080:8080" \ No newline at end of file + - "8080:8080" + restart: always + depends_on: + - postgres_db + + postgres_db: + image: postgres:14.1-alpine + restart: always + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - '5432:5432' From 32049c274fd885e56c96196807c6c9e4d8779991 Mon Sep 17 00:00:00 2001 From: Pratham Date: Sun, 11 Sep 2022 21:13:19 +0530 Subject: [PATCH 6/8] add env file --- .env.sample | 2 ++ .gitignore | 3 +++ docker-compose.yaml | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..68d527e --- /dev/null +++ b/.env.sample @@ -0,0 +1,2 @@ +POSTGRES_USER=postgres username +POSTGRES_PASSWORD=postgres password \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6ae93fa..3ee407f 100755 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ nymeria # miscellaneous .vscode/ + +# Env files +.env \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 04d3838..98a2660 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -18,7 +18,11 @@ services: image: postgres:14.1-alpine restart: always environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} ports: - '5432:5432' + volumes: + - ./pgdata:/var/lib/postgresql/data/pgdata +volumes: + pgdata: \ No newline at end of file From eb2b8d2257d4d9ccbb6ec6726fa9a6ec0aeb1ca3 Mon Sep 17 00:00:00 2001 From: Pratham Date: Thu, 22 Sep 2022 00:38:07 +0530 Subject: [PATCH 7/8] use named volumes --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 98a2660..6b46ab1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -23,6 +23,6 @@ services: ports: - '5432:5432' volumes: - - ./pgdata:/var/lib/postgresql/data/pgdata + - pgdata:/var/lib/postgresql/data volumes: pgdata: \ No newline at end of file From 743e30d99ad54a8d60f8c2deb6dc42673afcd1fe Mon Sep 17 00:00:00 2001 From: Pratham Date: Thu, 22 Sep 2022 00:59:35 +0530 Subject: [PATCH 8/8] remove extra-hosts flag from docker-compose file --- docker-compose.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 6b46ab1..7a812d2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,9 +5,7 @@ services: container_name: nymeria build: context: ./ - dockerfile: Dockerfile - extra_hosts: - - "localhost:127.0.0.1" + dockerfile: Dockerfile ports: - "8080:8080" restart: always