/dockerized-weatherapp

Web app to show weather forecast from OpenWeatherAPI

Primary LanguageJavaScript

Weatherapp

How to run -

  1. Clone the project using git clone

  2. Add a keys.js file in the folder /backend and add your OpenWeather API key as shown below -

const appid = "Your KEY here"; module.exports = appid;

  1. To run using docker, run the command docker-compose up in the main project folder.

  2. To manually run using npm (not recommended) you will need to run npm install in the project main folder, /backend, and /frontend folder separately. Once this is done, return to the main folder and run

npm start

Please note

I am using docker on docker-toolbox so I run my containers on a different IP. If you are running them on localhost, you will need to change the url to the backend in Line 46 of the file webpack.config.js in \frontend to

http://0.0.0.0:9000/api

Tasks

Mandatory

  • Get yourself an API key to make queries in the openweathermap. [Done]

  • Either run the app locally (using npm i && npm start) or move to the next step. [Done]

  • Add Dockerfile's in the frontend and the backend directories to run them virtually on any environment having docker installed. It should work by saying e.g. docker build -t weatherapp_backend . && docker run --rm -i -p 9000:9000 --name weatherapp_backend -t weatherapp_backend. If it doesn't, remember to check your api key first. [Done]

  • Add a docker-compose.yml -file connecting the frontend and the backend, enabling running the app in a connected set of containers. [Done]

Optional

  • The application now only reports the current weather. It should probably report the forecast e.g. a few hours from now. (tip: openweathermap api) [Done]

  • The developers are still keen to run the app and its pipeline on their own computers. Share the development files for the container by using volumes, and make sure the containers are started with a command enabling hot reload. [Done]

  • There are eslint errors. Sloppy coding it seems. Please help. [Done]

  • The app currently reports the weather only for location defined in the backend. Shouldn't it check the browser location and use that as the reference for making a forecast? (tip: geolocation) [Done]

  • There are no tests. Where are the tests? (tip: mocha or robot framework) Disclaimer: this is not an easy task. If you really want to try writing robot tests, start by creating a third container that gives expected weather data, and direct the backend queries there by redefining the MAP_ENDPOINT.

  • Set up the weather service in a free cloud hosting service, e.g. AWS or Google Cloud.

  • Write ansible playbooks for installing docker and the app itself.