This project builds a Docker image for Wego, a CLI weather application. The image is built in a multi-stage Dockerfile that compiles the Go binary statically (with CGO disabled) for compatibility with a minimal Alpine Linux image.
- Runtime Configuration: Uses environment variables (
OWM_API_KEYandLOCATION) to dynamically update the generated Wego configuration file (~/.wegorc) at container startup. - Wrapper Script: A shell script (
runWego.sh) ensures configuration values are updated before starting the application.
- Docker installed on your system.
- A valid OpenWeatherMap API key.
Run the following command in the project directory:
docker build -t wego .You can supply the following environment variables at runtime:
- OWM_API_KEY: Your OpenWeatherMap API key.
- LOCATION: The desired location for weather forecasting.
For example:
docker run -e OWM_API_KEY=YOUR_KEY -e LOCATION=YOUR_LOCATION wegoTo get the status of your weather after configurations have been made:
docker start -ai wego- Dockerfile: Multi-stage build file.
- runWego.sh: Startup script that updates the configuration file (
~/.wegorc) from environment variables and executes Wego. - .wegorc: The configuration file generated by Wego – updated during image build and runtime.
- Static Linking: If you encounter issues with the binary not executing on Alpine, ensure that
CGO_ENABLED=0is set during the build. - Configuration Issues: The script checks
~/.wegorcfor existing default values and updates them with provided environment variables. You can override these by passing variables at runtime.