From ae5f748357e1f2ff25e3c77655a6926f91302b1f Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:27:51 -0500 Subject: [PATCH] up --- .dockerignore | 8 ++++++++ .env | 6 +++--- Dockerfile | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ config.yml | 8 ++++---- 4 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dcd26b2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.git +.env +.air.conf +logs/ +session.db +node_modules/ +*.md +apiv2 diff --git a/.env b/.env index 01f92b3..9d2341d 100755 --- a/.env +++ b/.env @@ -6,9 +6,9 @@ APP_URL=https://admin.u-site.app DB_DRIVER=postgres DB_HOST=46.202.93.92 DB_PORT=5432 -DB_USER=usite -DB_PASS=P0sTgR3s!S3guro2025* -DB_NAME=usite +DB_USER=postgres +DB_PASS=0HZ3rRdsJ7paBAHEg07jtJU0RDuDKLthfXZnpsJZWD3ocMWzTQKFbPKlJUvFQFEA +DB_NAME=postgres MAIL_HOST=smtp.hostinger.com diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a047294 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,54 @@ +# ────────────────────────────────────────── +# Stage 1: Build del frontend (assets JS/CSS) +# ────────────────────────────────────────── +FROM node:20-alpine AS frontend +WORKDIR /app + +COPY package.json webpack.mix.js postcss.config.js tailwind.config.js ./ +RUN npm install --frozen-lockfile + +COPY resources/ resources/ +COPY public/ public/ +RUN npm run production + +# ────────────────────────────────────────── +# Stage 2: Build del binario Go +# ────────────────────────────────────────── +FROM golang:1.22-alpine AS builder +WORKDIR /app + +# Instalar dependencias del sistema necesarias para CGO (argon2, etc.) +RUN apk add --no-cache gcc musl-dev + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . +# Copiar assets del frontend compilados +COPY --from=frontend /app/public ./public + +RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -o apiv2 . + +# ────────────────────────────────────────── +# Stage 3: Imagen final mínima +# ────────────────────────────────────────── +FROM alpine:3.20 +WORKDIR /app + +# Certificados TLS y timezone +RUN apk add --no-cache ca-certificates tzdata + +# Copiar binario compilado +COPY --from=builder /app/apiv2 . + +# Copiar archivos estáticos y plantillas +COPY --from=builder /app/public ./public +COPY --from=builder /app/resources/views ./resources/views +COPY --from=builder /app/assets ./assets + +# config.yml se monta como volumen o se inyecta vía env en Coolify +COPY config.sample.yml ./config.yml + +EXPOSE 8080 + +ENTRYPOINT ["./apiv2", "-config", "config.yml"] diff --git a/config.yml b/config.yml index ad79c46..85a5b6c 100755 --- a/config.yml +++ b/config.yml @@ -9,11 +9,11 @@ database: port: 3306 postgres: &postgres driver: postgres - host: localhost + host: 46.202.93.92 username: postgres - password: postgres + password: 0HZ3rRdsJ7paBAHEg07jtJU0RDuDKLthfXZnpsJZWD3ocMWzTQKFbPKlJUvFQFEA port: 5432 - db_name: casbin + db_name: postgres sqlserver: &sqlserver driver: sqlserver host: localhost @@ -24,7 +24,7 @@ database: sqlite: &sqlite driver: sqlite db_name: "data.db" # Nombre del archivo de la base de datos SQLite - sqlserver: *sqlite # Cambia esto si quieres usar otra base de datos como predeterminada + default: *postgres server: &server name: "USITE "