This is a comprehensive guide to get you started with the DHBW Docker App, a containerized service orchestration for a TypeScript-based API. The application is composed of multiple services including an API service and a database service, all managed using Docker and orchestrated with Docker Compose.
Before you start, make sure you have the following installed:
- Docker
- Docker Compose
- Make (optional, for using the Makefile)
-
Clone the repository to your local machine.
-
Navigate to the root directory of the project.
-
Copy the
.env.examplefile to a new file named.envin the same directory.make .env
Adjust the environment variables in the
.envfile according to your setup. The following environment variables are required:DATABASE_USERNAMEThe username for the database.DATABASE_PASSWORDThe password for the database.DATABASE_NAMEThe name of the database.
-
Build and start the services using Docker Compose. You can use the provided Makefile for this. Run the following command in your terminal:
make dev
This command will start the containers for development. It builds the Docker images if they don't exist, removes orphan containers, and recreates the containers.
If you want to start the containers in detached mode (in the background), use the following command:
make dev:up
To stop and remove the containers, use the following command:
make dev:down
-
Once the services are up and running, you can access the API at
http://localhost:10000/api.
The Makefile provides additional commands for database migrations and queries:
make migration:createCreate a new TypeORM migration.make migration:generateGenerate a TypeORM migration from changes in the entities.make migration:revertRevert the last TypeORM migration.make migration:runRun pending TypeORM migrations.make migration:listShow a list of applied TypeORM migrations.make queryExecute a TypeORM query.
For API development, navigate to the api directory. The API is built with TypeScript and uses npm for package management. The following commands are available:
npm testRun tests.npm run lintCheck for linting errors.npm run lint:fixFix linting errors.npm run buildBuild the project.
For more details, refer to the README.md file in the api directory.
Contributions are welcome. Please make sure to follow the existing code style and run tests before submitting a pull request.
This project is licensed under the WTFPL License.