hargata / lubelog

LubeLogger is a web-based vehicle maintenance and fuel mileage tracker
https://lubelogger.com
MIT License
1.14k stars 59 forks source link

Docker Container #1

Closed hargata closed 10 months ago

hargata commented 10 months ago

Containerize the app.

fawqsir commented 10 months ago

This would be great! As a windows only platform excludes a lot of selfhosting users.

ionyx0 commented 10 months ago

Adding the following Dockerfile to the top level of your repo should get you started on containerization. I just built it locally from your 1.0.1 release and had it up and running perfectly.

Followed this from Microsoft.

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /App

COPY . ./
RUN dotnet restore
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /App
COPY --from=build-env /App/out .
EXPOSE 5000
CMD ["./CarCareTracker"]

Edit: I did have to change the localhost:5000 to 0.0.0.0:5000 to get the app to listen on the proper adapter.

FFCoder commented 10 months ago

Lol @ionyx0 this would have saved me some research (I've never had to build a Dotnet Docker file from scratch)

@hargata I have created a PR for this which does work. Please review and let me know if you have any questions. #5

ionyx0 commented 10 months ago

@FFCoder me either! I'm not a Dotnet developer so had basically zero to go on. I posted here as soon as I got it working hoping I could help @hargata or someone else along. Thanks for the PR!

hargata commented 10 months ago

I added a docker compose, can anyone verify if that works?

FFCoder commented 10 months ago

@hargata I may be mistaken, but I believe you can simplify the volume definitions a little bit since I believe this will largely be used as an example (the user will supply their own paths to where they want the volumes stored)

As an example, here is the plex example from LinuxServer ( a popular maintainer of Dockerfiles for self-hosted services)

image

hargata commented 10 months ago

@FFCoder I will get on that, thank you!

ionyx0 commented 10 months ago

I added a docker compose, can anyone verify if that works?

@hargata Confirmed working here (Linux)

zbellerose commented 10 months ago

Working here as well with Linux. Great work

florianschroen commented 10 months ago

Your docker-compose will work on your workstation, were the bind mount paths match to the project path. Beside this c: paths are usable under windows only, but most docker systems are running Linux based, I guess. So we want to as generic / compatible as possible and use named mounts.

In my pull request I used named mounts. This way docker manages where to store the data. At Linux systems the default path is /var/lib/docker/volumes//_data/

I added labels for a setup with the commonly used Traefik proxy server, too. But it works standalone without modification, too.

If you have any questions, just give me a shout. I can test and debug with windows and linux. And I am familiar with docker since years.

florianschroen commented 10 months ago

Would you like to have a look at my pr #6?

hargata commented 10 months ago

@florianschroen It is merged, I'll make a copy of the docker compose with the traefik portion commented out as well

hargata commented 10 months ago

Can anyone test the docker container again? If it's good I can close this FR.

ionyx0 commented 10 months ago

Can anyone test the docker container again? If it's good I can close this FR.

@hargata Works for me here using the current docker-compose.yml.

florianschroen commented 10 months ago

You can have a look at pr #8.

In addition, I saw a bug while testing the container.

The money amounts are prefixed with a symbol which is not displayed correctly. I guess yourintention was a $ sign prefix?

Do we want to include this charset encoding error in this FR? Or do we want to close it and handle the bug separately?

hargata commented 10 months ago

@florianschroen I believe that might be related to FR #3 Seems like dockerization is complete, I will close this FR