| ... | ... | @@ -4,16 +4,18 @@ Docker is a container management system, that enables to execute code regardless |
|
|
|
|
|
|
|
## Dockerfile
|
|
|
|
|
|
|
|
Dockerfiles are descriptive files that contain the instructions to build containers. This repository contains two docker files for the containers it creates. Arguments for this file can be found in the [official reference](https://docs.docker.com/reference/dockerfile/)
|
|
|
|
Dockerfiles are descriptive files that contain the instructions to build containers. This repository contains two docker files. Arguments for this file can be found in the [official reference](https://docs.docker.com/reference/dockerfile/)
|
|
|
|
|
|
|
|
### Database
|
|
|
|
|
|
|
|
This file is dedicated to create a container running a [Postgres database](https://www.postgresql.org). Currently, it takes the `postgres:16-alpine` image, sets the default password to `password` and exposes the default Postgres port `5432`. If you intend to make the database publicly accessible over the internet, you **need** to change password to something secure. Additionally, the Dockerfile copies the `schema.sql` file into `/docker-entrypoint-initdb.d/` upon container creation, which will execute the SQL statements in the file in postgres.
|
|
|
|
|
|
|
|
### API
|
|
|
|
|
|
|
|
The API Dockerfile uses the latest `node` image, copies `package.json` and `package-lock.json` into the container and installs the dependencies. Afterward it copies all code not excluded by `.dockerignore` into the container and runs `node .` to start the API server. By default the Dockerfile exposes the `3000` port in the container. If you intend to change this, you need to apply the same changes in `index.js`.
|
|
|
|
|
|
|
|
## docker-compose.yaml
|
|
|
|
|
|
|
|
Docker compose files contain the necessary instructions to start multiple containers and connect them to each other. They also provide the possibility to define container names, exposed ports and health checks.
|
|
|
|
|
|
|
|
### Network
|
| ... | ... | @@ -81,7 +83,8 @@ environment: |
|
|
|
If you changed any of these values when creating the database container, you need to change them here to.
|
|
|
|
|
|
|
|
### Port
|
|
|
|
Since both containers share a network, they won't be accessible. In order to enable interaction with the API, the `ports` key needs to be configures
|
|
|
|
|
|
|
|
Since both containers share a network, they won't be accessible. In order to enable interaction with the API, the `ports` key needs to be configured
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
ports:
|
| ... | ... | |
| ... | ... | |