Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Avoid committing Postgres build steps to tagged image#2

Merged
jnnnthnn merged 1 commit intomainfrom
@jnnnthnn/Avoid_committing_Postgres_build_steps_to_tagged_image
Oct 7, 2023
Merged

Avoid committing Postgres build steps to tagged image#2
jnnnthnn merged 1 commit intomainfrom
@jnnnthnn/Avoid_committing_Postgres_build_steps_to_tagged_image

Conversation

@jnnnthnn
Copy link
Contributor

@jnnnthnn jnnnthnn commented Oct 5, 2023

What changed

Avoids committing Postgres build steps to tagged image.

Why

We were running into issues with the Postgres container where rebuilds wouldn't be idempotent. This was addressed in #1 by checking for idempotency issues, but that didn't address the core issue.

The core issue is that by specifying image in the docker compose file, we'd tag the built image as the source postgres:15.4-bullseye image (docs).

Test plan

Running docker-compose build db_postgres twice in a row shouldn't lead to any issues.

Copy link
Contributor Author

jnnnthnn commented Oct 5, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@jnnnthnn jnnnthnn mentioned this pull request Oct 5, 2023
@jnnnthnn jnnnthnn requested a review from shabani1 October 5, 2023 00:07
@jnnnthnn jnnnthnn marked this pull request as ready for review October 5, 2023 00:07
- my-net

db_postgres:
image: postgres:15.4-bullseye
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare behavior with using --pull in the build command, which would also sidestep the idempotency issue since the remote image would be favored over the local one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So this statement is unnecessary, and docker/postgres/Dockerfile will anyway start from that image (postgres:15.4-bullseye) 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worse — this statement is harmful! It results in the built docker container to override the originally tagged/pulled image, which in turn is what causes the idempotency issue since we’re replaying the same steps on top of the built container instead of the base image.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh snap!

Copy link
Contributor

@shabani1 shabani1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

- my-net

db_postgres:
image: postgres:15.4-bullseye
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So this statement is unnecessary, and docker/postgres/Dockerfile will anyway start from that image (postgres:15.4-bullseye) 👍

@jnnnthnn jnnnthnn merged commit b4292ca into main Oct 7, 2023
@jnnnthnn jnnnthnn deleted the @jnnnthnn/Avoid_committing_Postgres_build_steps_to_tagged_image branch October 7, 2023 03:27
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

Successfully merging this pull request may close these issues.

2 participants