Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker image creation for crossreference #412

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

vladbogo
Copy link
Collaborator

No description provided.

@vladbogo vladbogo force-pushed the crossref_docker branch 3 times, most recently from 5b72332 to 1cef242 Compare April 11, 2024 14:09
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y build-essential mariadb-client libmariadbclient-dev
Copy link
Member

Choose a reason for hiding this comment

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

build-essential and mariadb-client looks odd - does it directly use mariadb executable? Could append ; rm -rf /var/lib/apt/lists/* for size reduction.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also:

  • please one package by line;
  • this lack of cleaning should have been catched by hadolint, can you make sure that it is run against this Dockerfile.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hadolint runs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

probably the mariadb-client and build-essential are not needed. some leftovers from other dockerfiles. I'll remove them and we'll see after testing

Copy link
Collaborator

Choose a reason for hiding this comment

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

hadolint runs

Nope, it does not, it runs on the wrong PATH...

~/buildbot/cross-reference remotes/vlad/crossref_docker ≡
.venv ❯ podman run -it -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint /mnt/Dockerfile
WARN[0000] "/" is not a shared mount, this could cause issues or missing mounts with rootless containers 
Trying to pull ghcr.io/hadolint/hadolint:latest...
Getting image source signatures
Copying blob db4123164570 done   | 
Copying config da13a5ec2e done   | 
Writing manifest to image destination
/mnt/Dockerfile:12 DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
/mnt/Dockerfile:12 DL3009 info: Delete the apt-get lists after installing something
/mnt/Dockerfile:18 DL3013 warning: Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>` or `pip install --requirement <requirements file>`

Copy link
Collaborator

Choose a reason for hiding this comment

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

DL3008 are disabled but DL3009 is not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The paths are too cryptic. I am not sure what it wants from pip

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DL3009 is also disabled. Anyway not sure what it wants now

cross-reference/Dockerfile Outdated Show resolved Hide resolved
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y build-essential mariadb-client libmariadbclient-dev
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also:

  • please one package by line;
  • this lack of cleaning should have been catched by hadolint, can you make sure that it is run against this Dockerfile.

@@ -0,0 +1,27 @@
# Use an official Python runtime as a parent image
FROM python:3.11-slim-buster
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe a good moment to try to upgrade to bullseye (or better alpine :-) )

cross-reference/Dockerfile Outdated Show resolved Hide resolved
@cvicentiu
Copy link
Member

cvicentiu commented Apr 12, 2024 via email

- uses: actions/checkout@v4
- name: Check Dockerfile with hadolint
run: |
docker run -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint /mnt/Dockerfile
Copy link
Collaborator

@fauust fauust Apr 15, 2024

Choose a reason for hiding this comment

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

Here is how to check the correct Dockerfile:

- docker run -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint /mnt/Dockerfile
+ docker run -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint /mnt/cross-reference/Dockerfile

note that $(pwd) the current repo root is mounted in /mnt in the container, also since the working directory is /mnt (that's what the -w does), this should also work:

docker run -i -v $(pwd):/mnt -w /mnt ghcr.io/hadolint/hadolint:latest hadolint cross-reference/Dockerfile

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't work because of line 16. All the next steps need to run in the cross-reference dir. So we either make this run in the parent, or copy the file

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I see, sorry missed that one. I am happy with any one of the mentioned solution.

@vladbogo vladbogo force-pushed the crossref_docker branch 6 times, most recently from b4c4e0f to 990998e Compare April 22, 2024 13:11
Copy link
Collaborator

@fauust fauust left a comment

Choose a reason for hiding this comment

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

Do you think that you could implement a very basic check step in the CI, just to make sure that the image seems to look good.

podman build . --tag ${{ env.REPO }}:crossreference
- name: Push images to local registry
run: |
for img in crossreference; do
Copy link
Collaborator

Choose a reason for hiding this comment

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

this for loop is useless

pip install --no-cache-dir -r requirements.txt

# Copy project
COPY ./crossreference /app/
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's probably cleaner to use this as a volume mount with the generated image. It would avoid regenerating the image anytime we change app code source...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's easier to have all contained in the image, for local Development purposes.
If this sounds sane, then also making use of DEV_ *container tags will help separate the two environments.

@RazvanLiviuVarzaru
Copy link
Collaborator

RazvanLiviuVarzaru commented Aug 14, 2024

What is the status of this PR?
Is it still work in progress / abandoned ?

Let's handle it appropriately so won't hang in the PR queue forever.
I can help with a review, but please help me with a quick recap of what is the purpose << No description provided. >> and what has happened so far + if there is any other information split over other channels (Zulip, Slack, e-mail, etc).

USER cr

# Run gunicorn
CMD ["bash", "-c", "python manage.py collectstatic --noinput && exec gunicorn crossreference.wsgi:application --bind 0.0.0.0:25432"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would really like to see a gunicorn configuration file, stored in the repository and exposed to the container as a mount.
https://docs.gunicorn.org/en/stable/settings.html

For example, we need to add the 60s timeout.

Copy link
Collaborator

Choose a reason for hiding this comment

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

definitively the way to proceed, yes!

@RazvanLiviuVarzaru
Copy link
Collaborator

RazvanLiviuVarzaru commented Nov 8, 2024

Another thing that is worth mentioning.
This PR needs a deployment pipeline, something like *deploy_crossreference*

Based on the current Git branching strategy,
--> Changes in DEV will trigger a deploy on DEV host. Here I propose to use hz-dev-bbm and use the MariaDB instance there (leverage the fact that now we have host networking everywhere, DEV is not under high load and CR is configured to look for DB on localhost anyway). @fauust sounds ok to you?
--> Changes on Main will trigger a deploy on hz-bbw5.

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

Successfully merging this pull request may close these issues.

5 participants