To get started with `ht-docker-node`, you need to have Docker installed on your machine. You can then pull the desired flavor of the Docker image from the relevant Docker registry.
`ht-docker-node` offers a variety of Docker image flavors to suit different needs. Below, we'll guide you through different use cases and configurations using these Docker images.
### Flavour Overview
- **:lts** - Node LTS version, equivalent to :latest
The following example covers multiple aspects including environment variables, volume mounting, and networking.
#### Dockerfile:
```Dockerfile
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Install desired Node.js version
RUN npmci install 16.0.0
# Create app directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install app dependencies
RUN npm ci
# Bundle app source
COPY . .
# Compile TypeScript
RUN npm run build
# Expose app port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]
```
#### Docker-Compose Configuration
If using Docker-Compose, create a `docker-compose.yml` file:
```yaml
version: '3.8'
services:
app:
image: your_app_name
build:
context: .
dockerfile: Dockerfile
ports:
- '3000:3000'
environment:
- NODE_ENV=production
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
networks:
- app-network
networks:
app-network:
driver: bridge
```
#### Running with Docker and Docker-Compose
To build the image:
```bash
docker-compose build
```
To run the services:
```bash
docker-compose up
```
#### Accessing the Container
```bash
docker exec -it your_container_name /bin/sh
```
### Conclusion
`ht-docker-node` offers a flexible, multifaceted solution for deploying Node.js applications in Docker containers. By leveraging its different flavours, you can efficiently manage Node.js versions, incorporate MongoDB, and handle TypeScript projects. Whether you are using simple Docker commands or elaborate Docker-Compose configurations, `ht-docker-node` caters to diverse deployment scenarios.
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.