jwilder / dockerize

Utility to simplify running applications in docker containers
MIT License
5k stars 414 forks source link

Multi-arch support specially arm64 #176

Open farhad-ris opened 2 years ago

farhad-ris commented 2 years ago

Is it possible to add multi-arch support specially ARM compatibility so we can benefit from AWS Graviton, and faster dev on Apple Silicon Macs

ezintz commented 2 years ago

I've just forked the repository and integrated a GitHub workflow for multi-platform build. Feel free to try it out yourself https://hub.docker.com/r/ezintz/dockerize/tags.

Tried it for a couple of images and it worked just fine.

blimmer commented 1 year ago

I ran into this and was able to get rid of dockerize by using the built-in docker-compose healthcheck and depends_on configurations.

Previous Config

version: "3.1"
services:
  db:
    build:
      context: .
      dockerfile: ./db.dockerfile
    ports:
      - 5434:5432

  db-wait:
    image: jwilder/dockerize
    command: dockerize -wait tcp://db:5432 -timeout 1m
    depends_on:
      - db

And if I wanted to wait for the db I'd do:

docker-compose up db-wait

New Config

Instead, I can now do:

version: "3.1"
services:
  db:
    build:
      context: .
      dockerfile: ./db.dockerfile
    ports:
      - 5434:5432
    healthcheck:
      test: ["CMD-SHELL", "pg_isready"]
      interval: 10s
      timeout: 5s
      retries: 5

and:

docker-compose up --wait db

For me, this was better than trying to figure out how to keep using dockerize. In fact, this is better than what I had before, before it doesn't just test the TCP port, it actually uses the pg_isready command to make sure postgres is ready for connections 😄

For other services that depend on the service with the healthcheck, you do need to specify that you want to wait for the service to be healthy. For example:

version: "3.1"
services:
  db:
    build:
      context: .
      dockerfile: ./db.dockerfile
    ports:
      - 5434:5432
    healthcheck:
      test: ["CMD-SHELL", "pg_isready"]
      interval: 10s
      timeout: 5s
      retries: 5
  tests:
    build:
      context: .
      dockerfile: ./tests.dockerfile
    depends_on:
      db:
        condition: service_healthy

Resources