I have pushed an image that uses golang and postgresql.When I am pulling that image on dockerhub and again running it on my machine it is not working properly.
Please provide some help. Here is my docker file and docker-compose.yml file
version: '3.8'
services:
app:
build: .
environment:
DATABASE_URL: "host=db user= password= dbname="
ports:
- "8080:8080"
depends_on:
- db
db:
image: postgres
restart: always
environment:
POSTGRES_USER:
POSTGRES_PASSWORD:
POSTGRES_DB:
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:
Dockerfile:
# syntax=docker/dockerfile:1
FROM golang:1.19-alpine
# Set destination for COPY
WORKDIR /app
# Download Go modules
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code. Note the slash at the end, as explained in
# https://docs.docker.com/engine/reference/builder/#copy
# Copy the source code
COPY . .
# Build
RUN CGO_ENABLED=0 GOOS=linux go build -o /go_docker_compose ./main.go
# Optional:
# To bind to a TCP port, runtime parameters must be supplied to the docker command.
# But we can document in the Dockerfile what ports
# the application is going to listen on by default.
# https://docs.docker.com/engine/reference/builder/#expose
EXPOSE 8080
# Run
CMD ["/go_docker_compose"]