maurerle / eralchemy2

Entity Relation Diagrams generation tool - DEPRECATED
https://github.com/eralchemy/eralchemy
Apache License 2.0
70 stars 17 forks source link

Create Dockerfile #45

Open paoliniluis opened 6 months ago

paoliniluis commented 6 months ago

Add a Dockerfile to build and run the application in a containerized environment

Fixes https://github.com/maurerle/eralchemy2/issues/46

maurerle commented 6 months ago

The ubuntu way is acutally a few MB smaller than using debian:stable-slim instead (both about 870MB). One should add rm -rf /var/lib/apt/lists/* to the apt command to remove the cache right away.

the plain python way does fail due to missing gcc

FROM python:3.12
WORKDIR /app
RUN apt-get update && apt-get install -y graphviz libgraphviz-dev && rm -rf /var/lib/apt/lists/*
RUN pip install eralchemy2

While the conda way creates a much larger image (1.6GB)

FROM continuumio/miniconda3
RUN conda install -y -c conda-forge eralchemy2

So this seems to be the best way to do this. Could you add some docs on how to use this and eventually create a ghcr image right away too?

paoliniluis commented 6 months ago

Sure, I'm still working on it as I can't run it from the container since it gives me a few errors, probably will finish it over this weekend

maurerle commented 5 months ago

This produces a docker image which is 320MB small:

FROM ubuntu:24.04

WORKDIR /app/eralchemy2

ENV PATH="/root/.local/bin:${PATH}"

RUN apt-get update && apt-get install --no-install-recommends -y build-essential python3-dev python3-pip pipx graphviz libgraphviz-dev && pipx install eralchemy2 && apt purge -y python3-dev build-essential && apt autoremove -y && rm -rf /var/lib/apt/lists/*

CMD ["eralchemy2"]

but I think I would go with the python-slim way instead of pipx (which is 326 MB):

FROM python:3.12-slim
WORKDIR /app
RUN apt-get update && \
         apt-get install --no-install-recommends -y \
             build-essential \
             python3-dev \
             graphviz \
             libgraphviz-dev && \
         pip install eralchemy2 && \
         apt purge -y python3-dev build-essential && \
         apt autoremove -y && \
         rm -rf /var/lib/apt/lists/*
CMD ["eralchemy2"]

To interact with it, it probably makes sense to mount a volume, otherwise I need to add a stdin and stdout mode as well

paoliniluis commented 5 months ago

@maurerle it's ready

maurerle commented 5 months ago

Nice! Would you also like to add a GitHub action which builds and pushes this image on a tag push – or should I add this myself? Thanks!

paoliniluis commented 5 months ago

That would be awesome but I would need the dockerhub access token (considering we want to push this to dockerhub). If you can create it and tell me the name I would be able to add this (next weekend for sure)

maurerle commented 5 months ago

I would only publish it to ghcr (Github container registry), for this, the default auth_token for repository actions is fine. I think you need https://github.com/docker/login-action?tab=readme-ov-file#github-container-registry and docker/build-push-action for this?

maurerle commented 2 months ago

Would you mind opening this PR against https://github.com/eralchemy/eralchemy? That would be very cool!