AccordBox / wagtail-tailwind-blog

Wagtail blog based on Tailwind CSS, Stimulus, it supports Markdown, Latex and user comments.
https://leanpub.com/buildblogwithwagtailcms
369 stars 85 forks source link

Project stuck on "website-web-1 | Waiting for PostgreSQL to become available..." on M1 Mac #139

Closed PGallace98 closed 1 year ago

PGallace98 commented 1 year ago

What happened?

I've followed the steps described on the e-book "Build Blog With Wagtail CMS (4.0.0)" on my M1 Mac and when Dockerizing the project (Chapter 4) I start encountering this issue.

The docker image and container build just fine but when I run the docker-compose logs -f command I encounter this issue

Screenshot 2023-02-02 at 10 43 58 AM

Additional details

I've followed the steps correctly, and the Dockerfile, the entrypoint, the start and the docker-compose.yml all match the book.

With the exact same configuration on my Windows 10 PC I don't encounter any problems at all.

michael-yin commented 1 year ago

@PGallace98

Thanks for your report

When you develop on M1 Mac, could you update the posgres image to https://hub.docker.com/r/arm64v8/postgres/ which is Arm Docker images instead of default x86/amd64

Since I have no M1/M2 Mac in hand so I can not not test if it works, but I hope it can help.

Thx.

PGallace98 commented 1 year ago

@michael-yin

Thank you for the reply.

Unfortunately updating to postgres arm image didn't fix the problem.

docker-compose.yml file for reference

Screenshot 2023-02-03 at 3 00 00 PM
michael-yin commented 1 year ago

@PGallace98

I did some research on this issue and figured it out

Why this issue happen

On apple silicon, we got Postgresql SCRAM authentication problem? so the program hang with "Waiting for PostgreSQL to become available" message.

Solution

We can use Rosetta to make our program work with "linux/amd64" instead of the "arm64"

Below are the steps:

  1. Please remove all "docker containers" and "docker images" for a clean env. https://stackoverflow.com/questions/44785585/how-can-i-delete-all-local-docker-images
  2. Git clone the project again without modification.

And then run command below

# install rosetta
softwareupdate --install-rosetta

# tell docker to build and run on amd64 platform
export DOCKER_DEFAULT_PLATFORM=linux/amd64
docker-compose build
docker-compose up

I already tested it on real M1 Mac and it worked.

Thx

PGallace98 commented 1 year ago

Thanks a lot it worked.