Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Docker Compose #89

Closed
pfcouto opened this issue Apr 6, 2023 · 0 comments
Closed

Error in Docker Compose #89

pfcouto opened this issue Apr 6, 2023 · 0 comments

Comments

@pfcouto
Copy link

pfcouto commented Apr 6, 2023

Click me Hello everyone I am following the video [[Backend #25] How to write docker-compose file and control service start-up orders with wait-for.sh](https://www.youtube.com/watch?v=jf6sQsz0M1M&ab_channel=TECHSCHOOL), but I can't make it work.

Note: some components, such as, docker images and containers have different names from the course.

Thank you for your help!

Here are my files:

docker-compose-yml

version: "3.9"
services:
postgres:
image: postgres:latest
environment:
- POSTGRES_USER=root
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=simple_bank
api:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
environment:
- DB_SOURCE=postgresql://root:secret@postgres:5432/simple_bank?sslmode=disable
depends_on:
- postgres
entrypoint: ["/app/wait-for.sh", "postgres:5432", "--", "/app/start.sh"]
command: ["/app/main"]

Dockerfile

#Build Stage

FROM golang:1.19-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o main main.go

Run stage

FROM alpine
WORKDIR /app
COPY --from=builder /app/main .
COPY /app/migrate ./migrate
COPY app.env .
COPY start.sh .
COPY wait-for.sh .
COPY db/migrations ./migration

EXPOSE 8080
CMD [ "/app/main" ]
ENTRYPOINT [ "/app/start.sh" ]

start.sh

#!/bin/sh

set -e

echo "RUN DB migration"
/app/migrate -path /app/migration -database "$DB_SOURCE" -verbose up

echo "start the app"
exec ls -la
exec "$@"

Then I run docker compose down and delete my api image. However when I do docker compose up I get this error (in the picture), it might be something that I am not seeing... My files structure is in the second picture

image

image

Solved the issue, I was deleting the wrong image

@pfcouto pfcouto closed this as completed Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant