Skip to content

Instantly share code, notes, and snippets.

@ArielSNunes
Last active December 4, 2024 13:24
Show Gist options
  • Select an option

  • Save ArielSNunes/1f5c500379402929190f122667e2adc5 to your computer and use it in GitHub Desktop.

Select an option

Save ArielSNunes/1f5c500379402929190f122667e2adc5 to your computer and use it in GitHub Desktop.
Basic Dockerfile and docker-compose.yml for NodeJS, with NestJS
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
POSTGRES_PASSWORD=
POSTGRES_USER=
POSTGRES_DB=
POSTGRES_HOST=
POSTGRES_PORT=
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?schema=public"
services:
db:
image: postgres
restart: always
env_file:
- .env
volumes:
- .docker/db:/var/lib/postgresql/data
ports:
- 5432:5432
FROM node:lts-alpine3.10
# Instala um bash no container
RUN apk add --no-cache bash
# Instala a CLI do NestJS
RUN npm i -g @nestjs/cli
# Instala um usuário node
USER node
# Diretório de trabalho dentro do container
WORKDIR /home/node/app
#!/bin/bash
yarn
yarn start:dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment