diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3600162 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM golang:1.23.4-alpine AS builder + +WORKDIR /app + +COPY go.mod go.sum ./ + +RUN go mod download && go mod verify + +COPY . . + +RUN go build -o transat-backend main.go + +EXPOSE 3000 + +ENV PORT=3000 + +ENTRYPOINT [ "./transat-backend" ] \ No newline at end of file diff --git a/compose.yml b/compose.yml index 66e604e..7ad126b 100644 --- a/compose.yml +++ b/compose.yml @@ -8,10 +8,32 @@ services: POSTGRES_USER: ${DB_USER} # Variable du fichier .env POSTGRES_PASSWORD: ${DB_PASS} # Variable du fichier .env ports: - - "5432:5432" # Mappe le port 5432 du conteneur au port 5432 de l'hôte + - "${DB_PORT}:5432" # Mappe le port 5432 du conteneur au port 5432 de l'hôte volumes: - postgres_data:/var/lib/postgresql/data # Persiste les données de la base de données + transat-backend: + build: + context: . + dockerfile: Dockerfile + command: go run main.go + ports: + - "${PORT}:3000" + depends_on: + - db + environment: + - DB_HOST=db + develop: + watch: + - path: . + action: sync+restart + target: /app + ignore: + - .env + - .git + - .gitignore + - .idea + volumes: postgres_data: driver: local \ No newline at end of file