Add dockerfile

This commit is contained in:
Zoe Roux 2024-08-30 01:05:03 +02:00
parent cf1e7497e2
commit 0c64d9b15d
No known key found for this signature in database
4 changed files with 72 additions and 0 deletions

12
auth/.dockerignore Normal file
View File

@ -0,0 +1,12 @@
Dockerfile*
*.md
.dockerignore
.gitignore
.env*
# generated via sqlc
dbc/
# genereated via swag
docs/
# vim: ft=gitignore

23
auth/Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM golang:1.23 AS build
WORKDIR /app
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
RUN go install github.com/swaggo/swag/cmd/swag@latest
COPY go.mod go.sum ./
RUN go mod download
COPY sqlc.yaml sql ./
RUN sqlc generate
COPY . .
RUN swag init --parseDependency
RUN CGO_ENABLED=0 GOOS=linux go build -o /keibi
FROM gcr.io/distroless/base-debian11
WORKDIR /
EXPOSE 4568
USER nonroot:nonroot
COPY --from=build /keibi /keibi
CMD ["/keibi"]

16
auth/Dockerfile.dev Normal file
View File

@ -0,0 +1,16 @@
FROM golang:1.23 AS build
WORKDIR /app
RUN go install github.com/bokwoon95/wgo@latest
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
RUN go install github.com/swaggo/swag/cmd/swag@latest
COPY go.mod go.sum ./
RUN go mod download
# COPY sqlc.yaml ./
# COPY sql/ ./
# RUN sqlc generate
EXPOSE 4568
CMD ["wgo", "run", "-race", "."]

View File

@ -84,6 +84,27 @@ services:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.front.rule=PathPrefix(`/`)" - "traefik.http.routers.front.rule=PathPrefix(`/`)"
auth:
build:
context: ./auth
dockerfile: Dockerfile.dev
restart: on-failure
depends_on:
postgres:
condition: service_healthy
ports:
- "4568:4568"
env_file:
- ./.env
volumes:
- ./auth:/app
labels:
- "traefik.enable=true"
- "traefik.http.routers.auth.rule=PathPrefix(`/auth/`)"
- "traefik.http.routers.auth.middlewares=auth-sp"
- "traefik.http.middlewares.auth-sp.stripprefix.prefixes=/auth"
- "traefik.http.middlewares.auth-sp.stripprefix.forceSlash=false"
scanner: scanner:
build: ./scanner build: ./scanner
restart: on-failure restart: on-failure