Files
FoodsharingOnboarding/Docker/publish-project.py
Andre Beging 859b0c3712 Add Docker support for FoodsharingSiegen project
Introduced Docker setup, including `docker-compose.yml`, `dockerfile.server`, and related Python helper scripts (`image-create.py`, `image-push.py`, `publish-project.py`, `publish-aio.py`) for building, managing, and deploying Docker images. Updated `.gitignore` to exclude published files, and renamed a field label in the Blazor component for better clarity.
2025-03-28 16:29:43 +01:00

39 lines
1.3 KiB
Python

import os
import subprocess
import sys
def main():
# Determine the absolute path of this script's directory
script_dir = os.path.dirname(os.path.abspath(__file__))
# Compute the path to the FoodsharingSiegen.Server project directory
# This assumes the following structure:
# files/
# Docker/ <-- this script resides here
# FoodsharingSiegen.Server/
project_dir = os.path.normpath(os.path.join(script_dir, '..', 'FoodsharingSiegen.Server'))
# Check if the project directory exists
if not os.path.isdir(project_dir):
print(f"Error: Project directory not found: {project_dir}")
sys.exit(1)
# Prepare the dotnet publish command
command = ["dotnet", "publish", project_dir]
print("Running command:", " ".join(command))
# Execute the command and capture the output
try:
result = subprocess.run(command, capture_output=True, text=True, check=True)
print(result.stdout)
if result.stderr:
print("Warnings/Errors:", result.stderr, file=sys.stderr)
except subprocess.CalledProcessError as e:
print("An error occurred while publishing the dotnet project.")
print(e.stdout)
print(e.stderr, file=sys.stderr)
sys.exit(e.returncode)
if __name__ == '__main__':
main()