r/docker • • 5h ago

whats your trick for keeping docker image sizes small without breaking stuff

4 Upvotes

i keep seeing images that are over a gig for simple apps. multi stage builds help but sometimes slim or alpine base images break things. curious how people handle this in practice.


r/docker • • 13h ago

Docker Error Help

Thumbnail reddit.com
1 Upvotes

r/docker • • 9h ago

How do you move forward time in the Docker stack

Thumbnail
reddit.com
0 Upvotes

r/docker • • 18h ago

how to make migrations service just run once in docker stack per deploy

0 Upvotes

EDIT: this is the thing that i had to add

   deploy:
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s

in a production setting what would be the way to make the migrations service just run once when a deployment is made

currently my service gets restarted each time even if the migrations were succesful, which is not what i want (or expected) i just want the migration to run once per deployment with the docker stack

or if you have another whole workflow for this im very open to read it :D

migrations:
    environment:
      DB_HOST: db
      DB_NAME_FILE: /run/secrets/db-name
      DB_PASSWORD_FILE: /run/secrets/db-password
      DB_PORT: "5432"
      DB_USER_FILE: /run/secrets/db-user
      GOOSE_DRIVER: postgres
      GOOSE_MIGRATION_DIR: /migrations
    image: mymigrationimage:latest
    networks:
      db_net: null
    secrets:
      - source: db-password
        target: /run/secrets/db-password
      - source: db-user
        target: /run/secrets/db-user
      - source: db-name
        target: /run/secrets/db-name
    volumes:
      - type: bind
        source: ./init/goose-entrypoint.sh
        target: /scripts/goose-entrypoint.sh
        bind:
          create_host_path: true

this is my customish docker image for the migrations (i just made a script that sets up the credentials variables using secrets for goose)

FROM ghcr.io/kukymbr/goose-docker:3.28.0
WORKDIR /migrations

RUN apk add --no-cache bash

COPY db/migrations/* /migrations

ENTRYPOINT ["/scripts/goose-entrypoint.sh"]