From cf020fe7a900f1d9326e75672e69d5c13380108c Mon Sep 17 00:00:00 2001 From: yamikarajput546 Date: Mon, 31 Jan 2022 13:53:53 +0530 Subject: [PATCH] added dockerfile and update docker-compose --- Dockerfile | 9 +++++++++ docker-compose.yaml | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..173d1c9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM golang:alpine + +WORKDIR /golang-docker + +ADD . . +COPY go.mod go.sum ./ +RUN go mod download + +ENTRYPOINT go build && ./golang-docker \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index ca8d9a1..8628d26 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,22 @@ -version: '3.8' -services: - db: +version: '3' +services: + web: + build: + context: . + dockerfile: ./Dockerfile + ports: + - 8080:8080 + volumes: + - .:/golang-docker + depends_on: + - database + container_name: golang-docker-web + environment: + - 'DB_PORT=3306' + - 'DB_HOST=database' + + + database: image: mysql:8.0.28 restart: always container_name: mysql @@ -16,10 +32,22 @@ services: - mysql_db:/var/lib/mysql networks: - main_network + + pma: + image: go-mysql:01 # buid image from Dockerfile named as go-mysql:01 + depends_on: + - database + ports: + - 5003:80 + environment: + - 'PMA_HOST=database' + - 'PMA_PORT=3306' + container_name: golang-docker-pma + volumes: mysql_db: name: mysql_db networks: main_network: - name: main_network + name: main_network \ No newline at end of file