Skip to content

Commit

Permalink
fix: fixe Docker file and test exists Dockerfile on workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcossIC committed Nov 16, 2024
1 parent e16f268 commit 3f242ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/mainServer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ jobs:
run: |
gcloud auth configure-docker $GCLOUD_REGION-docker.pkg.dev
# 4.5. Lint Dockerfile
- name: List files and check build context
run: |
ls -l ./backend
echo "Dockerfile exists? $(test -f ./backend/Dockerfile && echo 'Yes' || echo 'No')"
# 5. Construir la imagen Docker
- name: Build Docker image
working-directory: ./backend
Expand Down
13 changes: 5 additions & 8 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ FROM node:20-alpine AS base
RUN apk add --no-cache g++ make py3-pip libc6-compat
WORKDIR /app
RUN npm install -g typescript @nestjs/cli
COPY package.json package-lock.json tsconfig.json ./

# Fase de Construcción
FROM base AS builder
WORKDIR /app
COPY package.json package-lock.json tsconfig.json ./
COPY ./src ./src
COPY ./test ./test
COPY . .
RUN npm ci
# Declaración de los ARGs (se pasaran desde GitHub Actions)
ARG POSTGRES_URL
Expand All @@ -27,8 +26,6 @@ ENV POSTGRES_USER=$POSTGRES_USER
ENV POSTGRES_HOST=$POSTGRES_HOST
ENV POSTGRES_PASSWORD=$POSTGRES_PASSWORD
ENV POSTGRES_DATABASE=$POSTGRES_DATABASE
ENV NODE_ENV=production
ENV PORT=3000
RUN npm run build

# Fase de Producción
Expand All @@ -53,14 +50,14 @@ ENV POSTGRES_DATABASE=$POSTGRES_DATABASE
ENV NODE_ENV=production
ENV PORT=3000

RUN addgroup -g 1001 -S nodejs && adduser -S nestjs -u 1001
USER nestjs

# Copiar archivos relevantes de la fase de construcción
COPY --from=builder /app/package.json /app/package-lock.json ./
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/src ./src

RUN addgroup -g 1001 -S nodejs && adduser -S nestjs -u 1001
USER nestjs

EXPOSE 3000

CMD ["npm", "run", "start:prod"]

0 comments on commit 3f242ef

Please sign in to comment.