Exemplos de projetos rodando em containers Docker.
$ git clone url-do-projeto.git $ cd dockers #change to that directory
$ cd name-of-docker-project #change to that directory
$ cp .env.example .env #create the ".env" file like the ".env.example" file- Terminal 1: Run server @ localhost:
$ npm install #download dependencies
$ npx prisma migrate dev #if using prisma: init db file and create tables
$ npm run dev #if javascript: start the project by running the package.json script
$ python src/server.py #if python: start the project by running the src/server.py file- Terminal 2: Run database client with "docker-compose.yaml":
$ docker compose up #build the image and runs the container
$ ctrl + C #stop the container
$ docker compose down #delete the container- Terminal 2: Run database client with "Dockerfile":
$ docker build -t name-of-docker-image . #build the image
$ docker run [flags] name-of-docker-image #run the container
#flags:
# -it: run in the foreground
# -d: run in the background
# -p 4000:4000: map port used by the host -> port used by the container
# -env-file .env: get environment vars from the ".env" file
$ ctrl + C #stop the foreground container
$ docker stop name-of-docker-image #stop the background containerCurtiu o projeto? Marque esse repositório com uma Estrela ⭐!
