lundybernard / lundybernard/project_template

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

Open
#6 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
0
Avg merge
3m
Merged PRs (30d)
1

Description

:robot: _AI text below_ :robot:

## 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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing dockerfile, docker-compose.yaml, docker-compose.dev.yaml, bat/server/server.py, bat/server/cli.py, and container_tests/container_test.py, including the stale path and import references. Trace how the CLI, server defaults, compose files, and container test obtain the install path, service name, and port. Done means a fresh template rename or port change has one source of truth and the container test uses the current package and derived address.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, python
Domain
backend, devops, testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.