/
iezhelev
/
cppsh_micro
Обзор
Документация
Войти
/
iezhelev
/
cppsh_micro
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
Dockerfile.migration
39 строк
934 B
iezhelev
first commit
24 фев 2025, 13:52
24 фев 2025, 13:52
7ac2ca6
Код
Авторство
О чём код?
# Use a Go base image FROM golang:1.22-alpine AS builder # Set the working directory WORKDIR /app # Copy the Go module files and download dependencies COPY go.mod go.sum ./ RUN go mod download # Copy the source code COPY . . # Build the application with optimizations RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o migrate ./cmd/migrate/main.go # Create a minimal runtime image FROM alpine:latest # Set the working directory WORKDIR /app # Install necessary tools (e.g., `golang-migrate`) RUN apk add --no-cache bash # Copy the migration binary from the builder stage COPY --from=builder /app/migrate . # Copy the migration files into the container COPY internal/database/migrations /app/migrations # Set environment variables for database connection ENV DB_HOST=postgres ENV DB_USER=postgres ENV DB_PASSWORD=postgres ENV DB_NAME=cppsh_micro # Run the migration binary when the container starts CMD ["./migrate"]