dockerSupport: Added Basic Docker support to the application.

This commit is contained in:
Jonathon Chambers 2024-01-06 10:42:14 -05:00
parent 1c2368f5a1
commit 71c2e64daf
11 changed files with 34 additions and 7 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@ bin/
obj/ obj/
wwwroot/images/ wwwroot/images/
cartracker.db cartracker.db
data/cartracker.db
wwwroot/documents/ wwwroot/documents/
wwwroot/temp/ wwwroot/temp/
wwwroot/imports/ wwwroot/imports/

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
RUN mkdir -p /app/data
COPY --from=build-env /app/out .
ENTRYPOINT [ "dotnet", "CarCareTracker.dll" ]

View File

@ -6,7 +6,7 @@ namespace CarCareTracker.External.Implementations
{ {
public class CollisionRecordDataAccess : ICollisionRecordDataAccess public class CollisionRecordDataAccess : ICollisionRecordDataAccess
{ {
private static string dbName = "cartracker.db"; private static string dbName = "data/cartracker.db";
private static string tableName = "collisionrecords"; private static string tableName = "collisionrecords";
public List<CollisionRecord> GetCollisionRecordsByVehicleId(int vehicleId) public List<CollisionRecord> GetCollisionRecordsByVehicleId(int vehicleId)
{ {

View File

@ -6,7 +6,7 @@ namespace CarCareTracker.External.Implementations
{ {
public class GasRecordDataAccess: IGasRecordDataAccess public class GasRecordDataAccess: IGasRecordDataAccess
{ {
private static string dbName = "cartracker.db"; private static string dbName = "data/cartracker.db";
private static string tableName = "gasrecords"; private static string tableName = "gasrecords";
public List<GasRecord> GetGasRecordsByVehicleId(int vehicleId) public List<GasRecord> GetGasRecordsByVehicleId(int vehicleId)
{ {

View File

@ -6,7 +6,7 @@ namespace CarCareTracker.External.Implementations
{ {
public class NoteDataAccess: INoteDataAccess public class NoteDataAccess: INoteDataAccess
{ {
private static string dbName = "cartracker.db"; private static string dbName = "data/cartracker.db";
private static string tableName = "notes"; private static string tableName = "notes";
public Note GetNoteByVehicleId(int vehicleId) public Note GetNoteByVehicleId(int vehicleId)
{ {

View File

@ -6,7 +6,7 @@ namespace CarCareTracker.External.Implementations
{ {
public class ServiceRecordDataAccess: IServiceRecordDataAccess public class ServiceRecordDataAccess: IServiceRecordDataAccess
{ {
private static string dbName = "cartracker.db"; private static string dbName = "data/cartracker.db";
private static string tableName = "servicerecords"; private static string tableName = "servicerecords";
public List<ServiceRecord> GetServiceRecordsByVehicleId(int vehicleId) public List<ServiceRecord> GetServiceRecordsByVehicleId(int vehicleId)
{ {

View File

@ -6,7 +6,7 @@ namespace CarCareTracker.External.Implementations
{ {
public class TaxRecordDataAccess : ITaxRecordDataAccess public class TaxRecordDataAccess : ITaxRecordDataAccess
{ {
private static string dbName = "cartracker.db"; private static string dbName = "data/cartracker.db";
private static string tableName = "taxrecords"; private static string tableName = "taxrecords";
public List<TaxRecord> GetTaxRecordsByVehicleId(int vehicleId) public List<TaxRecord> GetTaxRecordsByVehicleId(int vehicleId)
{ {

View File

@ -6,7 +6,7 @@ namespace CarCareTracker.External.Implementations
{ {
public class VehicleDataAccess: IVehicleDataAccess public class VehicleDataAccess: IVehicleDataAccess
{ {
private static string dbName = "cartracker.db"; private static string dbName = "data/cartracker.db";
private static string tableName = "vehicles"; private static string tableName = "vehicles";
public bool SaveVehicle(Vehicle vehicle) public bool SaveVehicle(Vehicle vehicle)
{ {

View File

@ -5,6 +5,13 @@ A self-hosted, open-source vehicle service records and maintainence tracker.
## Why ## Why
Because nobody should have to deal with a homemade spreadsheet or a shoebox full of receipts when it comes to vehicle maintainence. Because nobody should have to deal with a homemade spreadsheet or a shoebox full of receipts when it comes to vehicle maintainence.
## Docker Setup (Recommended)
1. Install Docker
2. Clone this repo
3. Run `docker build -t lubelog .`
4. Run `docker run -d -p 80:5000 --name lubelog lubelog`
1. Optionally, you can mount a volume to the container to persist data. For example, `docker run -d -p 80:5000 -v /path/to/data:/app/data --name lubelog lubelog`
## Dependencies ## Dependencies
- Bootstrap - Bootstrap
- LiteDB - LiteDB

View File

@ -8,7 +8,7 @@
"Kestrel": { "Kestrel": {
"Endpoints": { "Endpoints": {
"http": { "http": {
"Url": "http://localhost:5000" "Url": "http://0.0.0.0:5000"
} }
} }
}, },

3
data/README.MD Normal file
View File

@ -0,0 +1,3 @@
# Data Directory
## Purpose:
Used to store the LiteDB database file. This directory can be mounted as a volume in the Dockerfile.