Skip to content

Commit

Permalink
refactor: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Siumauricio committed Feb 2, 2025
1 parent f5a1b96 commit 18ac449
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.golang
file: ./Dockerfile.monitoring
push: true
tags: |
siumauricio/monitoring:${{ github.ref_name == 'main' && 'latest' || 'canary' }}
Expand Down
41 changes: 0 additions & 41 deletions Dockerfile.golang

This file was deleted.

54 changes: 28 additions & 26 deletions Dockerfile.monitoring
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
FROM node:18-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
# Build stage
FROM golang:1.21-alpine3.19 AS builder

FROM base AS build
COPY . /usr/src/app
WORKDIR /usr/src/app
# Instalar dependencias necesarias
RUN apk add --no-cache gcc musl-dev sqlite-dev

RUN apt-get update && apt-get install -y python3 make g++ git && rm -rf /var/lib/apt/lists/*
# Establecer el directorio de trabajo
WORKDIR /app

# Install dependencies
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm --filter=./apps/monitoring install --frozen-lockfile
# Copiar todo el código fuente primero
COPY . .

# Deploy only the monitoring app
# Movernos al directorio de la aplicación golang
WORKDIR /app/apps/monitoring

ENV NODE_ENV=production
RUN pnpm --filter=./apps/monitoring run build
# Descargar dependencias
RUN go mod download

RUN pnpm --filter=./apps/monitoring --prod deploy /prod/monitoring
# Compilar la aplicación
RUN CGO_ENABLED=1 GOOS=linux go build -o main main.go

RUN cp -R /usr/src/app/apps/monitoring/dist /prod/monitoring/dist
# Etapa final
FROM alpine:3.19

FROM base AS dokploy
WORKDIR /app
# Instalar SQLite y otras dependencias necesarias
RUN apk add --no-cache sqlite-libs docker-cli

# Set production
ENV NODE_ENV=production
WORKDIR /app

RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Copiar el binario compilado y el archivo monitor.go
COPY --from=builder /app/apps/monitoring/main ./main
COPY --from=builder /app/apps/monitoring/main.go ./monitor.go

RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh && rm get-docker.sh
# COPY --from=builder /app/apps/golang/.env ./.env

# Copy only the necessary files
COPY --from=build /prod/monitoring/dist ./dist
COPY --from=build /prod/monitoring/package.json ./package.json
COPY --from=build /prod/monitoring/node_modules ./node_modules
# Exponer el puerto
ENV PORT=3001
EXPOSE 3001

CMD HOSTNAME=0.0.0.0 && pnpm start
# Ejecutar la aplicación
CMD ["./main"]

0 comments on commit 18ac449

Please sign in to comment.