Ajouter multistage build docker

Valeurs par défaut devraient fonctionner pour évaluer l'application hors-production
This commit is contained in:
Victor Lacasse-Beaudoin 2023-05-25 23:03:28 -04:00
parent e585b65565
commit 7aca281a3c
2 changed files with 70 additions and 16 deletions

35
v4/Dockerfile Normal file
View file

@ -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"]

View file

@ -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: