Quickstart with Docker
Getting started
1. Clone the repository
git clone https://github.com/kottster/kottster-template-js my-kottster-app
cd my-kottster-app
2. Build the Docker image
docker build -t my-kottster-app .
3. Run the container
docker run -d --name my-kottster-container \
-p 5480:5480 -p 5481:5481 \
-v $(pwd):/app \
-v /app/node_modules \
my-kottster-app
Here's what each flag does:
-d
- Run the container in the background--name my-kottster-container
- Assign a name to the container-p 5480:5480 -p 5481:5481
- Map the container ports to the host machine. The first port is for the main server, and the second port is for the dev-sync server (runs only in development mode)-v $(pwd):/app
- Mount the current directory to the/app
directory in the container-v /app/node_modules
- Mount thenode_modules
directory to the container. This is done to prevent thenode_modules
directory from being overwritten by the mounted volumemy-kottster-app
- The name of the Docker image you built in the previous step
4. Start the application
Development mode:
docker exec -it my-kottster-container /dev.sh
Production mode:
docker exec -it my-kottster-container /prod.sh
Development
The container is configured to synchronize your local codebase with the container. Any changes made to your local files will be immediately reflected in the running application.
Container Management
Stop the container:
docker stop my-kottster-container
Remove the container:
docker rm my-kottster-container
View container logs:
docker logs my-kottster-container
Configuration
You can customize the ports by modifying the Docker run command:
docker run -d --name my-kottster-container \
-p <host-port>:5480 -p <host-port>:5481 \
-v $(pwd):/app \
-v /app/node_modules \
my-kottster-app