From f9f3315091d1a8a927c5d9da2aa946eba98fb2e6 Mon Sep 17 00:00:00 2001 From: jannikf02 Date: Mon, 12 Aug 2024 20:50:01 +0000 Subject: [PATCH] Adds missing Files --- backend/aashub/main.go | 53 ------------------------------------------ ci/docker-compose.yml | 38 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 53 deletions(-) delete mode 100644 backend/aashub/main.go create mode 100644 ci/docker-compose.yml diff --git a/backend/aashub/main.go b/backend/aashub/main.go deleted file mode 100644 index 94b3ecf..0000000 --- a/backend/aashub/main.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "net/http" - "time" - - docs "github.com/aas-hub-org/aashub/docs" - "github.com/gin-contrib/cors" - "github.com/gin-gonic/gin" - swaggerfiles "github.com/swaggo/files" - ginSwagger "github.com/swaggo/gin-swagger" -) - -// @BasePath /api/v1 - -// PingExample godoc -// @Summary ping example -// @Schemes -// @Description do ping -// @Tags example -// @Accept json -// @Produce json -// @Success 200 {string} Helloworld -// @Router /example/helloworld [get] -func Helloworld(g *gin.Context) { - g.JSON(http.StatusOK, "helloworld") -} - -func main() { - r := gin.Default() - - // Configure CORS - corsConfig := cors.Config{ - AllowAllOrigins: true, - AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"}, - AllowHeaders: []string{"Origin", "Content-Length", "Content-Type", "Authorization"}, - ExposeHeaders: []string{"Content-Length"}, - AllowCredentials: true, - MaxAge: 12 * time.Hour, - } - r.Use(cors.New(corsConfig)) - - docs.SwaggerInfo.BasePath = "/api/v1" - v1 := r.Group("/api/v1") - { - eg := v1.Group("/example") - { - eg.GET("/helloworld", Helloworld) - } - } - r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) - r.Run(":9000") -} diff --git a/ci/docker-compose.yml b/ci/docker-compose.yml new file mode 100644 index 0000000..57c1048 --- /dev/null +++ b/ci/docker-compose.yml @@ -0,0 +1,38 @@ +services: + app: + image: mcr.microsoft.com/devcontainers/go:1-1.22-bookworm + container_name: app + volumes: + - ../:/workspace:cached + command: /bin/sh -c "cd /workspace/cmd/movie-api && go run main.go" + ports: + - 9000:9000 + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:9000/health > /proc/1/fd/1 2>/proc/1/fd/2 || exit 1"] + interval: 10s + timeout: 5s + retries: 5 + depends_on: + mariadb: + condition: service_healthy + + mariadb: + image: mariadb:10.6 + container_name: mariadb + environment: + MYSQL_ROOT_PASSWORD: rootpassword + MYSQL_DATABASE: moviesdb + MYSQL_USER: user + MYSQL_PASSWORD: password + volumes: + - ../mysql/init.sql:/docker-entrypoint-initdb.d/init.sql + ports: + - "3306:3306" + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + mysql-data: \ No newline at end of file