From 7aca281a3c8fdf08caeefd91aff81aadf52f5193 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Thu, 25 May 2023 23:03:28 -0400 Subject: [PATCH] Ajouter multistage build docker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Valeurs par défaut devraient fonctionner pour évaluer l'application hors-production --- v4/Dockerfile | 35 +++++++++++++++++++++++++++++ v4/docker-compose.yaml | 51 +++++++++++++++++++++++++++++------------- 2 files changed, 70 insertions(+), 16 deletions(-) create mode 100644 v4/Dockerfile diff --git a/v4/Dockerfile b/v4/Dockerfile new file mode 100644 index 0000000..26c5238 --- /dev/null +++ b/v4/Dockerfile @@ -0,0 +1,35 @@ +FROM golang:1.20.2 as build + +LABEL author="vlbeaudoin" + +WORKDIR /go/src/app + +COPY go.mod go.sum main.go ./ + +ADD cmd/ cmd/ +ADD data/ data/ +ADD handlers/ handlers/ +ADD models/ models/ +ADD web/ web/ + +RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o bottin . + +# Alpine + +FROM alpine:latest + +WORKDIR /app + +COPY --from=build /go/src/app/bottin /usr/bin/bottin + +CMD ["bottin", "--help"] + +# Debian + +#FROM debian:stable-20230502 + +#WORKDIR /app + +#COPY --from=build /go/src/app/haul /usr/bin/haul + +#CMD ["haul", "--help"] diff --git a/v4/docker-compose.yaml b/v4/docker-compose.yaml index 53b726c..09ab9be 100644 --- a/v4/docker-compose.yaml +++ b/v4/docker-compose.yaml @@ -1,29 +1,48 @@ services: db: - image: postgres:latest + image: 'docker.io/library/postgres:14.8' environment: POSTGRES_DATABASE: "${BOTTIN_POSTGRES_DATABASE}" POSTGRES_PASSWORD: "${BOTTIN_POSTGRES_PASSWORD}" POSTGRES_USER: "${BOTTIN_POSTGRES_USER}" - ports: - - '5432:5432' volumes: - - 'pgdata:/var/lib/postgresql/data' + - 'db-data:/var/lib/postgresql/data' + restart: 'unless-stopped' - #api: - # depends_on: db - - #web: - # depends_on: api - - adminer: - image: adminer - restart: always - ports: - - 8088:8080 + api: depends_on: - db + build: . + image: 'git.agecem.com/agecem/bottin/v4:latest' + ports: + - '1312:1312' + volumes: + - 'api-config:/etc/bottin' + restart: 'unless-stopped' + command: ['bottin', '--config', '/etc/bottin/api.yaml', 'api'] + + web: + depends_on: + - api + build: . + image: 'git.agecem.com/agecem/bottin/v4:latest' + ports: + - '2312:2312' + volumes: + - 'web-config:/etc/bottin' + restart: 'unless-stopped' + command: ['bottin', '--config', '/etc/bottin/api.yaml', 'web'] + +# adminer: +# image: adminer +# restart: always +# ports: +# - 8088:8080 +# depends_on: +# - db volumes: - pgdata: + db-data: + api-config: + web-config: