Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active February 23, 2026 22:55
Show Gist options
  • Select an option

  • Save Klerith/e7861738c93712840ab3a38674843490 to your computer and use it in GitHub Desktop.

Select an option

Save Klerith/e7861738c93712840ab3a38674843490 to your computer and use it in GitHub Desktop.

Revisions

  1. Klerith revised this gist Jul 6, 2022. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion build-run.md
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,7 @@ docker-compose -f docker-compose.prod.yaml --env-file .env.prod up --build
    docker-compose -f docker-compose.prod.yaml --env-file .env.prod up

    ## Nota
    Por defecto, __docker-compose__ usa el archivo ```.env``` por lo que si quieren se puede cambiar
    Por defecto, __docker-compose__ usa el archivo ```.env```, por lo que si tienen el archivo .env y lo configuran con sus variables de entorno de producción, bastaría con
    ```
    docker-compose -f docker-compose.prod.yaml up --build
    ```
  2. Klerith revised this gist Jul 6, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions build-run.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    # Build
    ## Build
    docker-compose -f docker-compose.prod.yaml --env-file .env.prod up --build

    # Run
    ## Run
    docker-compose -f docker-compose.prod.yaml --env-file .env.prod up

    # Nota
    ## Nota
    Por defecto, __docker-compose__ usa el archivo ```.env``` por lo que si quieren se puede cambiar
  3. Klerith revised this gist Jul 6, 2022. 2 changed files with 8 additions and 1 deletion.
    1 change: 0 additions & 1 deletion Dockerfile
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,6 @@ COPY package.json yarn.lock ./
    RUN yarn install --prod

    COPY --from=builder /app/dist ./dist
    COPY ./.env ./.env

    # # Copiar el directorio y su contenido
    # RUN mkdir -p ./pokedex
    8 changes: 8 additions & 0 deletions build-run.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    # Build
    docker-compose -f docker-compose.prod.yaml --env-file .env.prod up --build

    # Run
    docker-compose -f docker-compose.prod.yaml --env-file .env.prod up

    # Nota
    Por defecto, __docker-compose__ usa el archivo ```.env``` por lo que si quieren se puede cambiar
  4. Klerith revised this gist Jul 6, 2022. No changes.
  5. Klerith revised this gist Jul 6, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Dockerfile
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ COPY package.json yarn.lock ./
    RUN yarn install --prod

    COPY --from=builder /app/dist ./dist
    COPY ./.env /.env
    COPY ./.env ./.env

    # # Copiar el directorio y su contenido
    # RUN mkdir -p ./pokedex
  6. Klerith revised this gist Jul 6, 2022. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions docker-compose.prod.yaml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    version: '3'

    services:
    @@ -18,8 +17,8 @@ services:
    MONGODB: ${MONGODB}
    PORT: ${PORT}
    DEFAULT_LIMIT: ${DEFAULT_LIMIT}
    volumes:
    - ./:/var/www/pokedex
    # volumes:
    # - ./:/var/www/pokedex

    db:
    image: mongo:5
    @@ -29,5 +28,5 @@ services:
    - 27017:27017
    environment:
    MONGODB_DATABASE: nest-pokemon
    volumes:
    - ./mongo:/data/db
    # volumes:
    # - ./mongo:/data/db
  7. Klerith revised this gist Jul 6, 2022. 1 changed file with 42 additions and 32 deletions.
    74 changes: 42 additions & 32 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,43 @@
    # Install dependencies only when needed
    FROM node:18-alpine3.15 AS deps
    # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
    RUN apk add --no-cache libc6-compat
    WORKDIR /app
    COPY package.json yarn.lock ./
    RUN yarn install --frozen-lockfile

    version: '3'

    services:
    pokedexapp:
    depends_on:
    - db
    build:
    context: .
    dockerfile: Dockerfile
    image: pokedex-docker
    container_name: pokedexapp
    restart: always # reiniciar el contenedor si se detiene
    ports:
    - "${PORT}:${PORT}"
    # working_dir: /var/www/pokedex
    environment:
    MONGODB: ${MONGODB}
    PORT: ${PORT}
    DEFAULT_LIMIT: ${DEFAULT_LIMIT}
    # volumes:
    # - ./:/var/www/pokedex

    db:
    image: mongo:5
    container_name: mongo-poke
    restart: always
    ports:
    - 27017:27017
    environment:
    MONGODB_DATABASE: nest-pokemon
    volumes:
    - ./mongo:/data/db
    # Build the app with cache dependencies
    FROM node:18-alpine3.15 AS builder
    WORKDIR /app
    COPY --from=deps /app/node_modules ./node_modules
    COPY . .
    RUN yarn build


    # Production image, copy all the files and run next
    FROM node:18-alpine3.15 AS runner

    # Set working directory
    WORKDIR /usr/src/app

    COPY package.json yarn.lock ./

    RUN yarn install --prod

    COPY --from=builder /app/dist ./dist
    COPY ./.env /.env

    # # Copiar el directorio y su contenido
    # RUN mkdir -p ./pokedex

    # COPY --from=builder ./app/dist/ ./app
    # COPY ./.env ./app/.env

    # # Dar permiso para ejecutar la applicación
    # RUN adduser --disabled-password pokeuser
    # RUN chown -R pokeuser:pokeuser ./pokedex
    # USER pokeuser

    # EXPOSE 3000

    CMD [ "node","dist/main" ]
  8. Klerith revised this gist Jul 6, 2022. No changes.
  9. Klerith revised this gist Jul 6, 2022. 1 changed file with 32 additions and 36 deletions.
    68 changes: 32 additions & 36 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -1,37 +1,33 @@
    # Install dependencies only when needed
    FROM node:18-alpine3.15 AS deps
    # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
    RUN apk add --no-cache libc6-compat
    WORKDIR /app
    COPY package.json yarn.lock ./
    RUN yarn install --frozen-lockfile

    # Build the app with cache dependencies
    FROM node:18-alpine3.15 AS builder
    WORKDIR /app
    COPY --from=deps /app/node_modules ./node_modules
    COPY . .
    RUN yarn build


    # Production image, copy all the files and run next
    FROM node:18-alpine3.15 AS runner

    # Set working directory
    WORKDIR /usr/src/app

    COPY package.json yarn.lock ./

    RUN yarn install --prod

    COPY --from=builder /app/dist ./dist
    COPY ./.env /.env

    # Dar permiso para ejecutar la applicación
    # RUN adduser --disabled-password pokeuser
    # RUN chown -R pokeuser:pokeuser ./usr/src/app
    # USER pokeuser

    # EXPOSE 3000

    CMD [ "node","dist/main" ]
    version: '3'

    services:
    pokedexapp:
    depends_on:
    - db
    build:
    context: .
    dockerfile: Dockerfile
    image: pokedex-docker
    container_name: pokedexapp
    restart: always # reiniciar el contenedor si se detiene
    ports:
    - "${PORT}:${PORT}"
    # working_dir: /var/www/pokedex
    environment:
    MONGODB: ${MONGODB}
    PORT: ${PORT}
    DEFAULT_LIMIT: ${DEFAULT_LIMIT}
    # volumes:
    # - ./:/var/www/pokedex

    db:
    image: mongo:5
    container_name: mongo-poke
    restart: always
    ports:
    - 27017:27017
    environment:
    MONGODB_DATABASE: nest-pokemon
    volumes:
    - ./mongo:/data/db
  10. Klerith created this gist Jul 6, 2022.
    37 changes: 37 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    # Install dependencies only when needed
    FROM node:18-alpine3.15 AS deps
    # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
    RUN apk add --no-cache libc6-compat
    WORKDIR /app
    COPY package.json yarn.lock ./
    RUN yarn install --frozen-lockfile

    # Build the app with cache dependencies
    FROM node:18-alpine3.15 AS builder
    WORKDIR /app
    COPY --from=deps /app/node_modules ./node_modules
    COPY . .
    RUN yarn build


    # Production image, copy all the files and run next
    FROM node:18-alpine3.15 AS runner

    # Set working directory
    WORKDIR /usr/src/app

    COPY package.json yarn.lock ./

    RUN yarn install --prod

    COPY --from=builder /app/dist ./dist
    COPY ./.env /.env

    # Dar permiso para ejecutar la applicación
    # RUN adduser --disabled-password pokeuser
    # RUN chown -R pokeuser:pokeuser ./usr/src/app
    # USER pokeuser

    # EXPOSE 3000

    CMD [ "node","dist/main" ]
    24 changes: 24 additions & 0 deletions Dockerfile-simple
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    FROM node:18-alpine3.15

    # Set working directory
    RUN mkdir -p /var/www/pokedex
    WORKDIR /var/www/pokedex

    # Copiar el directorio y su contenido
    COPY . ./var/www/pokedex
    COPY package.json tsconfig.json tsconfig.build.json /var/www/pokedex/
    RUN yarn install --prod
    RUN yarn build


    # Dar permiso para ejecutar la applicación
    RUN adduser --disabled-password pokeuser
    RUN chown -R pokeuser:pokeuser /var/www/pokedex
    USER pokeuser

    # Limpiar el caché
    RUN yarn cache clean --force

    EXPOSE 3000

    CMD [ "yarn","start" ]
    33 changes: 33 additions & 0 deletions docker-compose.prod.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@

    version: '3'

    services:
    pokedexapp:
    depends_on:
    - db
    build:
    context: .
    dockerfile: Dockerfile
    image: pokedex-docker
    container_name: pokedexapp
    restart: always # reiniciar el contenedor si se detiene
    ports:
    - "${PORT}:${PORT}"
    # working_dir: /var/www/pokedex
    environment:
    MONGODB: ${MONGODB}
    PORT: ${PORT}
    DEFAULT_LIMIT: ${DEFAULT_LIMIT}
    volumes:
    - ./:/var/www/pokedex

    db:
    image: mongo:5
    container_name: mongo-poke
    restart: always
    ports:
    - 27017:27017
    environment:
    MONGODB_DATABASE: nest-pokemon
    volumes:
    - ./mongo:/data/db