Skip to content

Container and service identity is duplicated across dockerfile, compose files, and testsΒ #6

Description

@3M1LY-lb

πŸ€– AI text below πŸ€–

Finding

The container's identity β€” install path, service name, entrypoint, and port β€” is written out by hand in every file that needs it. A rename or a port change has to touch all of them, and nothing fails when one is missed.

Install path and entrypoint

  • dockerfile: ADD . /opt/bat, WORKDIR /opt/bat, ENTRYPOINT ["bat"], CMD ["start"]. The entrypoint is the console-script name declared in pyproject.toml and setup.py; start is a CLI subcommand.
  • docker-compose.dev.yaml: bind-mounts ./:/opt/bat, repeating the dockerfile's WORKDIR.

Service name

  • docker-compose.yaml and docker-compose.dev.yaml both name the service bat.

Port

  • both compose files: "5000:5000"
  • bat/server/server.py: start_server(..., port='5000') and start_api_server(..., port='5000')
  • bat/server/cli.py: --port default '5000'
  • container_tests/container_test.py: 'http://0.0.0.0:5000/', twice

The drift is not hypothetical

Two references on main are already stale, both survivors of an earlier rename:

  • docker-compose.dev.yaml comments the bind mount as # Override /opt/project with local dir in dev β€” it names a path the image no longer uses.
  • container_tests/container_test.py:6 does from project.tests.common_api_tests import CommonAPITest, a package name that no longer exists.

Neither broke a check, because nothing points at a single definition.

Suggested direction

Give each fact one home and reference it everywhere else:

  • the install path as a build ARG used by ADD and WORKDIR, mirrored once in the dev compose mount;
  • the port as one value both the compose files and the server default read β€” compose substitutes ${APP_PORT:-5000} from a .env file, and the server CLI already routes --port through server.port;
  • the test service address derived from that value instead of a literal.

The mechanism matters less than the outcome: renaming or re-porting a fresh copy of the template should be a change in one place, not a grep for bat and 5000 across five files.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions