Skip to content

Conversation

@ldionne
Copy link
Member

@ldionne ldionne commented Oct 23, 2025

This patch rewrites the Docker setup used to create a deployable container running a production LNT server.

  • Relocate all of the Docker-related files under docker/.
  • Document the various Docker-related files.
  • Update to Postgres 18. We might as well use the latest version available since we're standing this up from scratch.

With this setup, I am able to spin up a local LNT server instance with:

 docker compose --file docker/compose.yaml --env-file <secrets> up

An example of a secrets file would be

 LNT_DB_PASSWORD=foo
 LNT_AUTH_TOKEN=bar

This patch rewrites the Docker setup used to create a deployable
container running a production LNT server.

- Split the Docker image into two, a basic image with LNT installed
  and an image with the actual production server as an entry point.
- Relocate all of the Docker-related files under docker/.
- Document the various Docker-related files.
- Improve input validation in the docker entrypoint.
- Using proper Docker secrets to transmit sensitive information to
  the LNT webserver entry point and the Postgres database.
- Update to Postgres 18. We might as well use the latest version
  available since we're standing this up from scratch.

With this setup, I am able to spin up a local LNT server instance with:

     docker compose --file docker/compose.yaml --env-file <secrets> up

An example of a secrets file would be

     LNT_DB_PASSWORD=foo
     LNT_AUTH_TOKEN=bar
@ldionne ldionne requested a review from lukel97 October 23, 2025 21:30
Comment on lines 35 to 36
COPY . /var/tmp/lnt
WORKDIR /var/tmp/lnt
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid copying the entire source directory and only copy the required files to avoid clobbering the layers? This was originally done in 2d87edd, it helps keep image sizes small and reduces the cost of container registries over time etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, good point. Actually, I don't think we need anything except the installed Python package and the entrypoints, right? So we should be able to copy the sources during the build phase but not have them in the resulting image.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me know what you think of the new approach with --mount=type=bind. I'm (obviously) learning Docker so I hope my usage is alright, but IIUC this should result in the smallest possible image.

Copy link
Member Author

Choose a reason for hiding this comment

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

@lukel97 and I discussed this now at the LLVM Dev Meeting and basically we'd like to move the installation of dependencies into a separate step that runs before the installation of LNT itself. This allows caching the dependencies when only LNT itself changes.

This can be done by copying requirements.txt into the Docker image and getting rid of . in requirements.txt. Then, pip3 install -r requirements.txt will install only the dependencies, without requiring the actual sources in the Docker image.

This will be pursued in a separate PR.

# Install LNT itself
COPY . /var/tmp/lnt
WORKDIR /var/tmp/lnt
RUN pip3 install -r requirements.server.txt && apk --purge del .build-deps
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the client image be installing requirements.client.txt?

Copy link
Member Author

@ldionne ldionne Oct 24, 2025

Choose a reason for hiding this comment

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

This is actually creating an image that can run a server, I didn't think we wanted to produce an image that contains just the client, but I guess it makes some sense? In that case, I would suggest we produce three images:

  • llvm-lnt-client
  • llvm-lnt-server
  • llvm-lnt-server-prod

The idea is basically that we produce base images that just contain (the various flavours of) LNT, and then on top of that we build an image that has the actual configuration to run in production (the docker entry point, etc).

Let me know if you think we should be building three images, or something else.

@ldionne ldionne force-pushed the review/overhaul-docker branch from 1c00ef8 to 1bd2b5d Compare October 28, 2025 18:47
@ldionne
Copy link
Member Author

ldionne commented Oct 28, 2025

@lukel97 I removed the usage of Docker secrets from this PR. However, we get the following warnings when building the Docker image:

 4 warnings found (use docker --debug to expand):
 - SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "DB_PASSWORD") (line 40)
 - SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "AUTH_TOKEN") (line 40)
 - SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "DB_PASSWORD") (line 44)
 - SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "AUTH_TOKEN") (line 45)

We'll need to figure out how to best use Docker Secrets while still providing a readily-usable Docker image in a separate PR.


# Set up the actual entrypoint that gets run when the container starts.
COPY docker/docker-entrypoint.sh docker/lnt-wait-db /usr/local/bin/
ARG DB_USER DB_HOST DB_NAME DB_PASSWORD AUTH_TOKEN
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to use the ARG command? I think thats for encoding arguments into the image itself, but we want these to be configurable by whoever is using the image. What happens if we remove the ARG/ENV lines? Does the docker-compose file still work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that seems to work. I'm fine with doing it that way in this PR, but we should really move to using proper Docker secrets in a future patch.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I think I managed to make everything work with secrets, now.

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