From 8abe0f08937bba4462133d5fcf07936f618b0132 Mon Sep 17 00:00:00 2001 From: Richi78 Date: Thu, 26 Jun 2025 13:33:22 -0400 Subject: [PATCH 1/2] fix: Dockerfiles --- backend/Dockerfile | 17 +++++++---------- backend/routes/cors.go | 6 +++--- frontend/angular/Dockerfile | 1 + 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 2c67d29..5771fef 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine AS build +FROM golang:1.23-alpine AS builder WORKDIR /app @@ -10,21 +10,18 @@ RUN go mod download COPY . . # Compilar la aplicación -RUN CGO_ENABLED=0 GOOS=linux go build -o main . +RUN go build -o main . # Crear una imagen final más pequeña FROM alpine:latest WORKDIR /app -# Instalar certificados para HTTPS -RUN apk --no-cache add ca-certificates +# # Copiar el binario compilado desde la etapa anterior +COPY --from=builder /app/main . -# Copiar el binario compilado desde la etapa anterior -COPY --from=build /app/main . - -# Puerto que expondrá la aplicación +# # Puerto que expondrá la aplicación EXPOSE 8080 -# Comando para ejecutar la aplicación -CMD ["/app/main"] \ No newline at end of file +# # Comando para ejecutar la aplicación +CMD ["./main"] \ No newline at end of file diff --git a/backend/routes/cors.go b/backend/routes/cors.go index f683f74..08ed886 100644 --- a/backend/routes/cors.go +++ b/backend/routes/cors.go @@ -11,7 +11,7 @@ func SetupRouter() *gin.Engine { // Configuración de CORS config := cors.DefaultConfig() - config.AllowOrigins = []string{"http://localhost:4200"} // Tu aplicación Angular + config.AllowOrigins = []string{"*"} // Tu aplicación Angular config.AllowMethods = []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"} config.AllowHeaders = []string{"Origin", "Content-Type", "Accept", "Authorization"} @@ -56,7 +56,7 @@ func SetupRouter() *gin.Engine { api.GET("/courses/:id", GetCourse) api.POST("/courses", CreateCourse) api.GET("/course/:goto", GetCourseIDByGoto) - api.PUT("/courses/:id", UpdateCourse) - api.DELETE("/courses/:id", DeleteCourse) + api.PUT("/courses/:id", UpdateCourse) + api.DELETE("/courses/:id", DeleteCourse) return r } diff --git a/frontend/angular/Dockerfile b/frontend/angular/Dockerfile index 9860021..162641a 100644 --- a/frontend/angular/Dockerfile +++ b/frontend/angular/Dockerfile @@ -6,6 +6,7 @@ COPY . . RUN npm run build FROM nginx:alpine +RUN rm -rf /usr/share/nginx/html/* COPY --from=build /app/dist/angular/browser /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 \ No newline at end of file From 78d710f41fd74c2af8c4535fc168e0fc665bffe0 Mon Sep 17 00:00:00 2001 From: Richi78 Date: Thu, 26 Jun 2025 13:45:58 -0400 Subject: [PATCH 2/2] update: deploy.md --- deploy.md | 52 ++++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/deploy.md b/deploy.md index fedb364..5287f03 100644 --- a/deploy.md +++ b/deploy.md @@ -1,6 +1,22 @@ # Instrucciones de Despliegue -## Opción 1: Usando Docker +## Opción 1: Despliegue Completo usando Docker + +Para iniciar tanto el frontend como el backend simultáneamente: + +```bash +# Ejecutar docker-compose desde la raíz del proyecto +docker-compose up -d --build +``` + +### Acceso a los servicios + +- Frontend: [http://localhost:80](http://localhost:80) +- Backend: [http://localhost:8080](http://localhost:8080) + +--- + +## Opción 2: Usando Docker ### Frontend @@ -32,26 +48,12 @@ docker run -p 8080:8080 --name backend-contenedor backend 🌐 Acceder al backend: [http://localhost:8080](http://localhost:8080) -## Opción 2: Despliegue Completo usando Docker - -Para iniciar tanto el frontend como el backend simultáneamente: - -```bash -# Ejecutar docker-compose desde la raíz del proyecto -docker-compose up -d -``` - -### Acceso a los servicios - -- Frontend: [http://localhost:80](http://localhost:80) -- Backend: [http://localhost:8080](http://localhost:8080) - ---- +--- ## Sin Docker -Gorilla/mux sirve para las rutas -Leer la docuemntacion [https://github.com/gorilla/mux](https://github.com/gorilla/mux) +Gin sirve para las rutas +Leer la docuemntacion [https://gin-gonic.com/en/docs/](https://gin-gonic.com/en/docs/) Air sirve para auto reload Leer la documentacion [https://github.com/air-verse/air](https://github.com/air-verse/air) @@ -66,19 +68,9 @@ https://gorm.io/docs/ ````bash cd .\backend -go get -u github.com/gorilla/mux - -go install github.com/air-verse/air@latest - -go get -u gorm.io/gorm -go get -u gorm.io/driver/postgres - - - -```bash -cd .\backend +go mod download -air +go run main.go ```` ## Docker con postgres