cooklang / cookcli

Command line program which provides a suite of tools to create shopping lists and maintain recipes.
https://cooklang.org
MIT License
733 stars 32 forks source link

Add Dockerfile #90

Open leonbeon opened 7 months ago

leonbeon commented 7 months ago

I think adding a Dockerfile would really benefit this project! Here is the one I currently use for a Raspberry Pi, based on Alpine Linux.

from alpine:3.18

ARG DOWNLOAD_URL="https://github.com/cooklang/cookcli/releases/latest/download/cook-aarch64-unknown-linux-musl.tar.gz"

# Set workdir to /app
WORKDIR /app

# Download CookCLI file
ADD ${DOWNLOAD_URL} .

# Untar binary
RUN tar -xvf cook-*

# Remove tar
RUN rm *.tar.gz

# Expose default port (9080)
EXPOSE 9080

# Run Server
ENTRYPOINT ["./cook", "server", "--host", "./recipes"]

You could overwrite the download URL with --build-arg, currently it points to the latest build of the aarch64 version. Also, I'm not sure if logs would be redirected to docker logs output, since it seems like the cook binary doesn't output anything anyway?

Also, I spent hours realising that the --host argument is missing. Maybe add that to the docs?

dubadub commented 7 months ago

@leonbeon I'm not certain I understand the motivation for this docker file. I guess the goal is to have a server running, but why not to use default system tools for that (systemd for Linux, launchd for MacOS, probably something exists for Windows too)? Using Docker is a very narrow use-case.

dubadub commented 7 months ago

Good point about the docs, it still refers old Swift base CLI, need to update.

leonbeon commented 7 months ago

I think the benefit of having a Dockerfile on the top level of the repo is that you can build directly from GitHub. But you're right, using Docker is just one of many ways to build this. Then again, why not also add a systemd config for easy deployment?