Skip to content
Snippets Groups Projects
Commit fdd66cc2 authored by jenda's avatar jenda
Browse files

Add docker file

parent fb935f4f
No related branches found
No related tags found
No related merge requests found
.direnv/ .direnv/
.idea/
## Ignore Visual Studio temporary files, build results, and ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons. ## files generated by popular Visual Studio add-ons.
## ##
......
version: '3.8'
services:
flightlognet:
build:
context: ../FlightLogNet
dockerfile: Dockerfile
ports:
- "5000:80" # Upravit port
environment:
- DOTNET_RUNNING_IN_CONTAINER=true
- ConnectionStrings__DefaultConnection=Host=postgresdb;Port=5432;Database=flightlog;Username=postgres;Password=secret
depends_on:
- postgresdb
restart: unless-stopped
postgresdb:
image: postgres:15
container_name: postgresdb
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secret
POSTGRES_DB: flightlog
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine # syntax=docker/dockerfile:1
# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/go/dockerfile-reference/
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
################################################################################
# Learn about building .NET container images:
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md
# Create a stage for building the application.
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
COPY . /source
WORKDIR /source
# This is the architecture you’re building for, which is passed in by the builder.
# Placing it here allows the previous steps to be cached across architectures.
ARG TARGETARCH
# Build the application.
# Leverage a cache mount to /root/.nuget/packages so that subsequent builds don't have to re-download packages.
# If TARGETARCH is "amd64", replace it with "x64" - "x64" is .NET's canonical name for this and "amd64" doesn't
# work in .NET 6.0.
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app
# If you need to enable globalization and time zones:
# https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md
################################################################################
# Create a new stage for running the application that contains the minimal
# runtime dependencies for the application. This often uses a different base
# image from the build stage where the necessary files are copied from the build
# stage.
#
# The example below uses an aspnet alpine image as the foundation for running the app.
# It will also use whatever happens to be the most recent version of that tag when you
# build your Dockerfile. If reproducibility is important, consider using a more specific
# version (e.g., aspnet:7.0.10-alpine-3.18),
# or SHA (e.g., mcr.microsoft.com/dotnet/aspnet@sha256:f3d99f54d504a21d38e4cc2f13ff47d67235efeeb85c109d3d1ff1808b38d034).
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
WORKDIR /app WORKDIR /app
COPY ./bin/Release/net7.0/linux-musl-x64/publish ./
ENTRYPOINT ["./FlightLogNet"] # Copy everything needed to run the app from the "build" stage.
\ No newline at end of file COPY --from=build /app .
# Switch to a non-privileged user (defined in the base image) that the app will run under.
# See https://docs.docker.com/go/dockerfile-user-best-practices/
# and https://github.com/dotnet/dotnet-docker/discussions/4764
USER $APP_UID
ENTRYPOINT ["dotnet", "FlightLogNet.dll"]
## 🛠️ **Instalační příručka pro projekt FlightLogNet**
---
## 📋 **Předpoklady (Prerekvizity)**
Před nasazením aplikace je nutné zajistit následující:
1. **Serverové požadavky**
- Minimální hardwarové požadavky serveru jsou specifikovány ve specifikaci.
2. **Přístup ke zdrojovému kódu**
- TODO: Ujistěte se, že máte přístup k repozitáři projektu.
3. **Nainstalované nástroje**
- **Docker** ve verzi uvedené ve specifikaci: [Oficiální návod na instalaci Docker Engine](https://docs.docker.com/get-docker/).
- **Docker Compose** ve verzi uvedené ve specifikaci?: [Oficiální dokumentace Docker Compose](https://docs.docker.com/compose/install/).
---
## 🚀 **Postup instalace**
### 1️⃣ **Stažení zdrojového kódu**
Otevřete terminál nebo příkazovou řádku a spusťte následující příkaz:
```bash
git clone https://gitlab.fel.cvut.cz/nahodpe1/sep-2024-team-d
```
### 2️⃣ Spuštění Docker Engine
Ujistěte se, že máte spuštěný Docker Engine.
- **Linux**: Docker běží jako služba, ověřte pomocí:
```bash
sudo systemctl start docker
sudo systemctl enable docker
```
- **Windows/Mac**: Spusťte Docker Desktop a ujistěte se, že běží.
### 3️⃣ Přepnutí do adresáře projektu
Přesuňte se do složky projektu:
```bash
cd sep-2024-team-d
```
### 4️⃣ Nasazení aplikace s Docker Compose
Spusťte následující příkaz pro sestavení a spuštění kontejnerů:
```bash
docker compose up --build
```
- Docker Compose vytvoří všechny služby (včetně aplikace a databáze PostgreSQL).
- Po dokončení bude aplikace dostupná na http://localhost:5000. TODO port a url?
### 🛠️ Řešení potíží
- **Docker Compose nefunguje?**
- Zkontrolujte, že Docker a Docker Compose jsou správně nainstalované:
```bash
docker --version
docker-compose --version
```
- **Problémy s připojením k databázi?**
- Ujistěte se, že služba postgresdb běží. Zkontrolujte logy:
```bash
docker-compose logs postgresdb
```
- **Chyba při stahování repozitáře?**
- Ověřte svůj SSH klíč a přístupová práva v GitLabu.
### 📞 Technická podpora
- V případě potíží se obraťte na technickou podporu společnosti SEPTIK PRO s.r.o.
- **Email**: support@septippro.cz
- **Telefon**: +420 000 000 000
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment