Skip to content

Commit

Permalink
feat: use ENV variables in Dockerfile.prod
Browse files Browse the repository at this point in the history
  • Loading branch information
EjembiEmmanuel committed Aug 28, 2024
1 parent 21e5003 commit effad94
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 0 additions & 1 deletion backend/Dockerfile.consumer
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ FROM golang:1.22.2-alpine
RUN apk add --no-cache bash curl git jq

# Copy over the configs
COPY ./configs/docker-database.config.json ./database.config.json
COPY ./configs/docker-backend.config.json ./backend.config.json

# Copy over the app
Expand Down
21 changes: 20 additions & 1 deletion backend/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ FROM --platform=linux/amd64 golang:1.22.2-alpine
RUN apk add --no-cache bash curl git jq

# Copy over the configs
COPY ./configs/prod-database.config.json ./database.config.json
COPY ./configs/prod-backend.config.json ./backend.config.json

# Copy over the app
Expand All @@ -12,6 +11,26 @@ COPY ./backend/go.mod ./backend/go.sum ./
RUN go mod download
COPY ./backend .

# Argument for Redis host and port
ARG REDIS_HOST
ARG REDIS_PORT

# Set Redis host and port environment variables
ENV REDIS_HOST=${REDIS_HOST}
ENV REDIS_PORT=${REDIS_PORT}

# Argument for Postgres host, port, user, and database
ARG POSTGRES_HOST
ARG POSTGRES_PORT
ARG POSTGRES_USER
ARG POSTGRES_DATABASE

# Set Postgres host, port, user, and database environment variables
ENV POSTGRES_HOST=${POSTGRES_HOST}
ENV POSTGRES_PORT=${POSTGRES_PORT}
ENV POSTGRES_USER=${POSTGRES_USER}
ENV POSTGRES_DATABASE=${POSTGRES_DATABASE}

# Build the app & run it
RUN go build -o main ./cmd/backend/backend.go

Expand Down

0 comments on commit effad94

Please sign in to comment.