Pizza-UI is a reusable microservice for creating and serving UI components, leveraging Templ to generate templates. This project provides a server running on a specified port via the UI_PORT
environment variable, offering a customizable user interface setup for other microservices, such as auth
, orders
, and more.
- Templ-based HTML component generation
- Environment-based configuration for project name and port
- Ready for containerization and cloud-native deployment
- Customizable and reusable for multiple applications
- Go (latest stable version recommended)
- Docker (optional for containerized deployment)
git clone https://github.com/username/pizza-ui.git
cd pizza-ui
### 2. Initial Configuration
To set up the project, define the project name and the port on which it will run. You can configure this through a `.env` file.
1. Copy the example environment file:
```bash
cp .env.example .env
-
Edit
.env
to set thePROJECT_NAME
andUI_PORT
environment variables:PROJECT_NAME=pizza-ui UI_PORT=8080
Alternatively, you can directly set these variables in your environment.
To start the server, run:
go run main.go
This will start the server on the port defined by UI_PORT
. If you haven't set UI_PORT
, the server defaults to port 8080
.
Once the server is running, open your web browser and go to:
http://localhost:8080
Or use the port you specified in UI_PORT
.
To run the Pizza-UI service as a Docker container:
-
Build the Docker Image:
docker build -t pizza-ui .
-
Run the Docker Container:
docker run -p 8080:8080 -e UI_PORT=8080 pizza-ui
Adjust the
UI_PORT
variable as needed.
For testing, use:
go test ./...