Merge branch 'feat/docker' into 'main'
ci: Containerization of the app See merge request blakeridgway/turf-tasker!2
This commit is contained in:
		
						commit
						8f71f32e9b
					
				
					 3 changed files with 99 additions and 8 deletions
				
			
		
							
								
								
									
										34
									
								
								Dockerfile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								Dockerfile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | ||||||
|  | # RUN WITH docker run -e "ASPNETCORE_URLS=http://+:80" -p 8080:80 turf-tasker-app | ||||||
|  | # This is only temporary | ||||||
|  | 
 | ||||||
|  | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||||||
|  | WORKDIR /src | ||||||
|  | 
 | ||||||
|  | COPY ["turf_tasker.csproj", "./"] | ||||||
|  | RUN dotnet restore "turf_tasker.csproj" | ||||||
|  | 
 | ||||||
|  | COPY . . | ||||||
|  | 
 | ||||||
|  | WORKDIR "/src" | ||||||
|  | 
 | ||||||
|  | RUN dotnet build "turf_tasker.csproj" -c Release -o /app/build | ||||||
|  | 
 | ||||||
|  | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS publish | ||||||
|  | WORKDIR /src | ||||||
|  | 
 | ||||||
|  | COPY --from=build "/src/turf_tasker.csproj" "./" | ||||||
|  | RUN dotnet restore "turf_tasker.csproj" | ||||||
|  | 
 | ||||||
|  | COPY . . | ||||||
|  | 
 | ||||||
|  | WORKDIR "/src" | ||||||
|  | RUN dotnet publish "turf_tasker.csproj" -c Release -o /app/publish /p:UserAppHost=false | ||||||
|  | 
 | ||||||
|  | FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final | ||||||
|  | WORKDIR /app | ||||||
|  | 
 | ||||||
|  | COPY --from=publish /app/publish . | ||||||
|  | 
 | ||||||
|  | COPY turf_tasker.db . | ||||||
|  | 
 | ||||||
|  | ENTRYPOINT ["dotnet", "turf_tasker.dll"] | ||||||
							
								
								
									
										69
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										69
									
								
								README.md
									
										
									
									
									
								
							|  | @ -1,4 +1,4 @@ | ||||||
| # MowLog | # Turf Tasker | ||||||
| 
 | 
 | ||||||
| A simple but powerful ASP.NET Core MVC application designed to track lawn care activities.  | A simple but powerful ASP.NET Core MVC application designed to track lawn care activities.  | ||||||
| **This project serves as a hands-on learning exercise to explore and master the fundamentals of the ASP.NET Core MVC framework,  | **This project serves as a hands-on learning exercise to explore and master the fundamentals of the ASP.NET Core MVC framework,  | ||||||
|  | @ -9,6 +9,7 @@ from data modeling with Entity Framework Core to building dynamic, data-driven v | ||||||
| -   Log lawn care events (Mowing, Watering, Fertilizing, etc.). | -   Log lawn care events (Mowing, Watering, Fertilizing, etc.). | ||||||
| -   Track mowing patterns to ensure a healthy lawn and prevent ruts. | -   Track mowing patterns to ensure a healthy lawn and prevent ruts. | ||||||
| -   Dashboard homepage showing the last time key activities were performed and what the next mowing pattern should be. | -   Dashboard homepage showing the last time key activities were performed and what the next mowing pattern should be. | ||||||
|  | -   A dedicated section for general lawn care tips. | ||||||
| -   A filterable and sortable log of all past activities. | -   A filterable and sortable log of all past activities. | ||||||
| -   Clean, responsive UI using Bootstrap. | -   Clean, responsive UI using Bootstrap. | ||||||
| 
 | 
 | ||||||
|  | @ -19,11 +20,67 @@ from data modeling with Entity Framework Core to building dynamic, data-driven v | ||||||
| -   **Frontend:** HTML, CSS, Bootstrap 5, JavaScript (with jQuery) | -   **Frontend:** HTML, CSS, Bootstrap 5, JavaScript (with jQuery) | ||||||
| -   **Development Environment:** JetBrains Rider on Fedora Linux | -   **Development Environment:** JetBrains Rider on Fedora Linux | ||||||
| -   **Version Control:** Git with GitLab | -   **Version Control:** Git with GitLab | ||||||
|  | -   **Containerization:** Docker | ||||||
| 
 | 
 | ||||||
| ## How to Run | ## How to Run | ||||||
| 
 | 
 | ||||||
| 1.  Clone the repository. | You can run this application either directly using the .NET SDK or via Docker. | ||||||
| 2.  Ensure you have the .NET 8 SDK installed. | 
 | ||||||
| 3.  Navigate to the project directory and run `dotnet restore`. | ### Option 1: Run Natively (using .NET SDK) | ||||||
| 4.  Run `dotnet ef database update` to create the initial SQLite database. | 
 | ||||||
| 5.  Run `dotnet run` to start the application. | 1.  **Clone the repository:** | ||||||
|  |     ```bash | ||||||
|  |     git clone https://gitlab.com/blakeridgway/turf-tasker.git | ||||||
|  |     ``` | ||||||
|  | 2.  **Navigate to the project directory:** | ||||||
|  |     ```bash | ||||||
|  |     cd turf-tasker  | ||||||
|  |     ``` | ||||||
|  |     (If your `turf_tasker.csproj` is directly in the cloned `turf_tasker` folder, you might skip this `cd`.) | ||||||
|  | 3.  **Ensure .NET 8 SDK is installed:** | ||||||
|  |     ```bash | ||||||
|  |     dotnet --version | ||||||
|  |     ``` | ||||||
|  |     (Should show 8.x.x) | ||||||
|  | 4.  **Restore dependencies:** | ||||||
|  |     ```bash | ||||||
|  |     dotnet restore | ||||||
|  |     ``` | ||||||
|  | 5.  **Create/Update the database:** | ||||||
|  |     ```bash | ||||||
|  |     dotnet ef database update | ||||||
|  |     ``` | ||||||
|  |     This will create the `turf_tasker.db` SQLite file and seed initial data. | ||||||
|  | 6.  **Run the application:** | ||||||
|  |     ```bash | ||||||
|  |     dotnet run | ||||||
|  |     ``` | ||||||
|  | 7.  **Access in browser:** Your application will typically run on `https://localhost:5062` or a similar port, which will be displayed in the terminal output. | ||||||
|  | 
 | ||||||
|  | ### Option 2: Run with Docker | ||||||
|  | 
 | ||||||
|  | 1.  **Ensure Docker is installed and running** on your system. | ||||||
|  |     *   [Docker Installation Guide](https://docs.docker.com/engine/install/) | ||||||
|  | 2.  **Clone the repository** (if you haven't already): | ||||||
|  |     ```bash | ||||||
|  |     git clone https://gitlab.com/blakeridgway/turf-tasker.git | ||||||
|  |     ``` | ||||||
|  | 3.  **Navigate to the project directory**: | ||||||
|  |     ```bash | ||||||
|  |     cd turf_tasker  | ||||||
|  |     ``` | ||||||
|  | 4.  **Build the Docker image:** | ||||||
|  |     ```bash | ||||||
|  |     docker build -t turf-tasker-app . | ||||||
|  |     ``` | ||||||
|  |     This command builds the image and tags it as `turf-tasker-app`. | ||||||
|  | 5.  **Run the Docker container:** | ||||||
|  |     ```bash | ||||||
|  |     docker run -e "ASPNETCORE_URLS=http://+:80" -p 8080:80 turf-tasker-app | ||||||
|  |     ``` | ||||||
|  |     *   `-e "ASPNETCORE_URLS=http://+:80"` explicitly configures the app to listen on HTTP port 80 inside the container. | ||||||
|  |     *   `-p 8080:80` maps port 8080 on your host machine to port 80 inside the container. | ||||||
|  | 6.  **Access in browser:** | ||||||
|  |     ``` | ||||||
|  |     http://localhost:8080 | ||||||
|  |     ``` | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| { | { | ||||||
|   "ConnectionStrings": { |   "ConnectionStrings": { | ||||||
|     "DefaultConnection": "Data Source=MowLog.db" |     "DefaultConnection": "Data Source=turf_tasker.db" | ||||||
|   }, |   }, | ||||||
|   "Logging": { |   "Logging": { | ||||||
|     "LogLevel": { |     "LogLevel": { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Blake Ridgway
						Blake Ridgway