Skip to content

Commit

Permalink
more refactor for env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
juandjara committed Nov 20, 2023
1 parent 10d9674 commit 5496499
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_INVIDIOUS_URL=
INVIDIOUS_URL=
1 change: 0 additions & 1 deletion .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
VITE_INVIDIOUS_URL: ${{ secrets.VITE_INVIDIOUS_URL }}

jobs:
build-and-publish:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ FreeTunes is an app to listen to background music from youtub and download it as

## Requirements
To run this project on your environment you will need one thing
- A publicly accesible [Invidious](https://invidious.io/) instance. To provide this you can use the `VITE_INVIDIOUS_URL` env var. If this environment variable is not detected the app will refuse to start.
- A publicly accesible [Invidious](https://invidious.io/) instance. To provide this you can use the `INVIDIOUS_URL` env var. If this environment variable is not detected the app will refuse to start.

## Running from docker image

A docker image is published to ghcr.io with every commit of this repository. You can give this project a try with a `docker run --rm` command like this:
```sh
docker run --rm -e VITE_INVIDIOUS_URL=htps://your.invidious.instance.url.here -p 3000:3000 ghcr.io/juandjara/freetunes
docker run --rm -e INVIDIOUS_URL=htps://your.invidious.instance.url.here -p 3000:3000 ghcr.io/juandjara/freetunes
```

You can now access the running service on https://localhost:300
Expand All @@ -27,15 +27,15 @@ services:
image: ghcr.io/juandjara/freetunes
container_name: freetunes
environment:
- VITE_INVIDIOUS_URL=htps://your.invidious.instance.url.here # note this variable will be used by both frontend and backend, so it must publicly accesible
- INVIDIOUS_URL=htps://your.invidious.instance.url.here # note this variable will be used by both frontend and backend, so it must publicly accesible
ports:
- '3000:3000'
```
## Running locally with node
You can also run this project locally from source using `node`. To do so, follow these steps:
1. Install dependencies with `npm install` or the package manager you use (yarn, pnpm, etc)
2. Copy the file `.env.example` to a new file called `.env` and fill in the `VITE_INVIDIOUS_URL` variable there.
2. Copy the file `.env.example` to a new file called `.env` and fill in the `INVIDIOUS_URL` variable there.
3. Run the command `npm run dev`. This will bring up the dev server with HMR
4. Now you can access the app on http://localhost:3000

Expand Down
4 changes: 2 additions & 2 deletions api/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const invidiousURL = import.meta.env.VITE_INVIDIOUS_URL
const invidiousURL = process.env.INVIDIOUS_URL

if (!invidiousURL) {
throw new Error('VITE_INVIDIOUS_URL environment variable is not set')
throw new Error('INVIDIOUS_URL environment variable is not set')
}

export default {
Expand Down
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const INVIDIOUS_URL = import.meta.env.VITE_INVIDIOUS_URL as string
export const API_URL = '/api'

0 comments on commit 5496499

Please sign in to comment.