-
Star
(134)
You must be signed in to star a gist -
Fork
(52)
You must be signed in to fork a gist
-
-
Save Klerith/e7861738c93712840ab3a38674843490 to your computer and use it in GitHub Desktop.
| 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 |
| 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 |
| 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" ] |
nice
Gracias por la buena información. ¿Algún curso de docker que recomiendes?
El tiene uno de docker
Excelente, muchas gracias! Sólo una nota, toca cambiar la versión de node en el Dockerfile para que se ejecute con las versiones más recientes de Node.
Saludos!
Este gist me ha salvado en muchas, gracias Fernando por el contenido de calidad.
Obtengo un error:
RUN apk add --no-cache libc6-compat
[+] Running 0/11: apk: not found
- Service pokedex Building 94.4s
failed to solve: process "/bin/sh -c apk add --no-cache libc6-compat" did not complete successfully: exit code: 127
Obtengo un error: docker-compose -f docker-compose.prod.yaml --env-file .env.prod up --build
0.559 [1/4] Resolving packages...
1.031 [2/4] Fetching packages...
36.99 error file-type@21.0.0: The engine "node" is incompatible with this module. Expected version ">=20". Got "18.12.1"
37.00 error Found incompatible module.
37.00 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Dockerfile:7
5 | WORKDIR /app
6 | COPY package.json yarn.lock ./
7 | >>> RUN yarn install --frozen-lockfile
8 |
9 | # Build the app with cache dependencies
failed to solve: process "/bin/sh -c yarn install --frozen-lockfile" did not complete successfully: exit code: 1
Si tienen problemas al correr el primer comando, solo actualicen la imagen del alpine al 20 en el archivo de Dockerfile @PR0C3S:
FROM node:20-alpine
Gracias por la buena información.
¿Algún curso de docker que recomiendes?