Before launching the development environment, the application needs the API key for openweathermap to function properly.
To launch the development environment, you need to have Docker and Docker Compose installed on your machine.
The API key can be stored in the .env file in the project root.
Before launching the application, create the file with such content:
APPID=<your-openweathermap-api-key>
Once you have Docker and Docker Compose installed and obtained the API key, navigate to the project root and enter the following command:
docker compose up --buildTo launch the project locally without Docker and Docker Compose, you need to install NodeJS and npm.
To launch the project you need to start both frontend and backend servers.
To launch development servers, perform the following steps starting from the project root.
- Launch frontend:
cd frontend/ npm i npm start - Launch backend:
cd backend/ npm i APPID=<your-openweathermap-api-key> npm run dev
Regardless of which method you've used, frontend and backend can be accessed via the following addresses:
- backend: http://localhost:9000
- frontend: http://localhost:8000
In development mode, you can freely edit files and the respective servers will restart once changes are detected.
docker pull ghcr.io/eerikas/weather-app
docker run -p 9000:9000 -e APPID=<your-openweathermap-api-key> ghcr.io/eerikas/weather-appNavigate to the project root and do the following commands:
docker build -t weather-app .
docker run -p 9000:9000 -e APPID=<your-openweathermap-api-key> weather-appTo create and launch the production build on your machine, you need to do the following steps:
- Navigate to the
frontend/folder. - Install dependencies and build the production version:
npm i npm run build
- Compiled files will be stored in
frontend/dist. - Copy the
dist/folder to thebackend/folder. - Navigate to the
backend/folder. - Install dependencies and start the server:
npm i APPID=<your-openweathermap-api-key> npm start
The application is automatically deployed to GCP Cloud Run and can be accessible at https://weather-app-eficode-4zhltaqspq-lz.a.run.app/
The setup process requires having gcloud CLI installed on your machine and having a Google Cloud account.
The application is automatically rebuilt and redeployed once there is a new push on main branch and there are no linting errors.
This environment (Docker, Docker Compose and this repo) can be deployed to Ubuntu-based machines using Ansible. More information is provided with the ansible playbooks