https://github.com/dipiash/vite-nginx-dynamic-env-variables-example
https://github.com/dipiash/vite-nginx-dynamic-env-variables-example
docker environment-variables envsubst nginx react vite
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dipiash/vite-nginx-dynamic-env-variables-example
- Owner: dipiash
- License: mit
- Created: 2024-05-13T17:17:13.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-17T08:00:00.000Z (about 1 year ago)
- Last Synced: 2025-01-13T16:23:08.906Z (5 months ago)
- Topics: docker, environment-variables, envsubst, nginx, react, vite
- Language: TypeScript
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://hits.seeyoufarm.com)
# Vite, Nginx and environment variables for a static website at runtime
It's an axample for article: [Vite, Nginx and environment variables for a static website at runtime](https://medium.com/quadcode-life/vite-nginx-and-environment-variables-for-a-static-website-at-runtime-f3d0b2995fc7)
1. Create `.env` file
```sh
cp .env.example .env
```
2. Install node_modules
```sh
npm i
```
3. Build the Docker image
```sh
docker build -t vite-nginx-dynamic-env-variables-example .
```
4. Run the image with environment variable `VITE_VERSION=FROM_NGINX`
```sh
docker run -p 81:80 -e VITE_VERSION=FROM_NGINX vite-nginx-dynamic-env-variables-example
```
5. Open http://127.0.0.1:81 and see the result