Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine AS build
FROM golang:1.23-alpine AS builder

WORKDIR /app

Expand All @@ -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"]
# # Comando para ejecutar la aplicación
CMD ["./main"]
6 changes: 3 additions & 3 deletions backend/routes/cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand Down Expand Up @@ -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
}
52 changes: 22 additions & 30 deletions deploy.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions frontend/angular/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading