The server can be configured using the following environment variables:
PORT
The port on which the server listens for incoming HTTP requests.
Default::8080
Example:PORT=":3000"
-
STATIC_DIRThe absolute path to the directory from which static files are served. Default: Current working directory (.) Example:STATIC_DIR="/app/web" -
WORKER_COUNTThe number of worker goroutines to handle requests. Default: Number of available CPU cores Example:WORKER_COUNT=16
-
Clone the repository:
git clone https://github.com/cilginc/webserver-go.git cd webserver-go -
Build the server:
go build -o bin ./cmd/server cd bin -
Start the server:
# Using default configuration ./server # With custom port and static directory PORT=":3000" STATIC_DIR="./web/www" ./server
Add the following service definition to your docker-compose.yml file:
services:
webserver:
image: ghcr.io/cilginc/server:latest
container_name: webserver
ports:
- "3000:3000"
volumes:
- ./www:/www
environment:
- PORT=:3000
- STATIC_DIR=/wwwThen start the container:
docker compose up -d