Git Product home page Git Product logo

foodtrucks's Introduction

SF Food Trucks

San Francisco's finger-licking street food now at your fingertips.

img

This is a fun application built to accompany the docker curriculum which is a comprehensive tutorial on getting started with Docker targeted especially at beginners. The app is built with Flask on the backend and Elasticsearch is the search engine powering the searches. The front-end is built with React and the beautiful maps are courtesy of Mapbox.

If you find the design of the website a bit ostentatious, blame Genius for giving me the idea of using this color scheme. Lastly, the data for the food trucks is made available in the public domain by SF Data.

Docker

There are two different ways of getting the app up and running with Docker. To learn more about how these two differ, check out the docker curriculum.

Docker Network
$ ./setup-docker.sh
Docker Compose
$ docker-compose up

The app can also be easily deployed on AWS Elastic Container Service. Once you have aws ecs cli installed, you can run the following to deploy it on ECS!

$ ./setup-aws-ecs.sh

Learn more at docker-curriculum.

foodtrucks's People

Contributors

afifshowkathali avatar dependabot[bot] avatar diguage avatar lempiy avatar oobug avatar prakhar1989 avatar ronnyfm avatar shelsoloa avatar tartansandal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

foodtrucks's Issues

Foodtruck nodes do not display on map.

Build step 9 RUN apt-get install -yq nodejs gives this warning, then skips subsequent dependencies
npm WARN [email protected] No repository field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
I tried using the more recent setup version of 12.x instead of 10.x, but got the same results.

Curl suggestion didn't work

Leaving this for future learners, if you receive an error

PS C:\Users\User> curl 0.0.0.0:9200
curl : Unable to connect to the remote server
At line:1 char:1

  • curl 0.0.0.0:9200
  •   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    
    

It is exposed on that port as can be seen from the inspect extract "Ports": {
"9200/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "9200"
}

But using curl 127.0.0.1:9200 did work

Docker build fails on symbolic link

The step "RUN ln -s /usr/bin/nodejs /usr/bin/node" in the Dockerfile fails with the following error:
Step 6/13 : RUN ln -s /usr/bin/nodejs /usr/bin/node ---> Running in 076b724790c3 ln: failed to create symbolic link '/usr/bin/node': File exists The command '/bin/sh -c ln -s /usr/bin/nodejs /usr/bin/node' returned a non-zero code: 1

I had to comment-out this line and then it worked.

Problem with docker compose

When I use docker-compose up command, there is a problem with foodtrucks_web_1 and I don't know why.
web_1 | /usr/local/lib/python3.6/dist-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.26.6) or chardet (3.0.4) doesn't match a supported version!
web_1 | RequestsDependencyWarning)
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Out of retries. Bailing out...
foodtrucks_web_1 exited with code 1
It just fails to create a container for FoodTrucks for me.

I am using Ubuntu vm in VirtualBox of a Windows 10 Environment.
Please help, thank you.

Map interaction does not work

Searching for food trucks works in the current master branch. However, hovering over and selecting records from the search results does not do anything on the map. Instead, the map stays empty regardless of the populated search results.

App does not display correctly in Chrome localhost

First, thanks for your guide :)

Problem

I follow the guide, specially, the 3.2 Docker Network.
So, I run in my machine (build ended without any error):

$ git clone https://github.com/prakhar1989/FoodTrucks
$ cd FoodTrucks
$ docker-compose up

But this is the problem:
image

In Firefox, works perfectly.
Google Chrome does print the map, but ES works, because print the search results in the sidebar.

My machine

OS: Debian 8.6
Google Chrome: Version 56.0.2924.87 (64-bit)
Firefox: 45.7.0
docker --version: Docker version 1.13.0, build 49bf474
docker-compose --version: docker-compose version 1.11.0, build 6de1806

docker-compose.yml, with elasticsearch:2.3:

➜  FoodTrucks git:(master) cat docker-compose.yml 
version: "2"
services:
  es:
    image: elasticsearch:2.3
  web:
    image: prakhar1989/foodtrucks-web
    command: python app.py
    ports:
      - "5000:5000"
    volumes:
      - .:/code

Dockerfile:

➜  FoodTrucks git:(master) cat Dockerfile 
# start from base
FROM ubuntu:14.04
MAINTAINER Prakhar Srivastav <[email protected]>

# install system-wide deps for python and node
RUN apt-get -yqq update
RUN apt-get -yqq install python-pip python-dev
RUN apt-get -yqq install nodejs npm
RUN ln -s /usr/bin/nodejs /usr/bin/node

# copy our application code
ADD flask-app /opt/flask-app
WORKDIR /opt/flask-app

# fetch app specific deps
RUN npm install
RUN npm run build
RUN pip install -r requirements.txt

# expose port
EXPOSE 5000

# start app
CMD [ "python", "./app.py" ]

docker ps:

➜  FoodTrucks git:(master) docker ps        
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                    NAMES
ed366ab9b38a        prakhar1989/foodtrucks-web   "python app.py"          3 days ago          Up About an hour    0.0.0.0:5000->5000/tcp   foodtrucks_web_1
67b79e6b15c9        elasticsearch:2.3            "/docker-entrypoin..."   3 days ago          Up About an hour    9200/tcp, 9300/tcp       foodtrucks_es_1

docker network ls:

NETWORK ID          NAME                 DRIVER              SCOPE
455c0890fea8        bridge               bridge              local
19cbf15d629e        foodtrucks_default   bridge              local
b1db12647c9a        host                 host                local
7e3ffa5351bf        none                 null                local

Docker Build fails: No module markupsafe

Building the docker image of the flask app, there is a ModuleNotFoundError:

#15 2.878 Complete output from command python setup.py egg_info:
#15 2.878 Traceback (most recent call last):
#15 2.878 File "", line 1, in
#15 2.878 File "/tmp/pip-build-oynx730y/MarkupSafe/setup.py", line 61, in
#15 2.878 run_setup(True)
#15 2.878 File "/tmp/pip-build-oynx730y/MarkupSafe/setup.py", line 44, in run_setup
#15 2.878 ext_modules=ext_modules if with_binary else [],
#15 2.878 File "/usr/lib/python3/dist-packages/setuptools/init.py", line 129, in setup
#15 2.878 return distutils.core.setup(**attrs)
#15 2.878 File "/usr/lib/python3.6/distutils/core.py", line 121, in setup
#15 2.878 dist.parse_config_files()
#15 2.878 File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 494, in parse_config_files
#15 2.878 ignore_option_errors=ignore_option_errors)
#15 2.878 File "/usr/lib/python3/dist-packages/setuptools/config.py", line 106, in parse_configuration
#15 2.878 meta.parse()
#15 2.878 File "/usr/lib/python3/dist-packages/setuptools/config.py", line 382, in parse
#15 2.878 section_parser_method(section_options)
#15 2.878 File "/usr/lib/python3/dist-packages/setuptools/config.py", line 355, in parse_section
#15 2.878 self[name] = value
#15 2.878 File "/usr/lib/python3/dist-packages/setuptools/config.py", line 173, in setitem
#15 2.878 value = parser(value)
#15 2.878 File "/usr/lib/python3/dist-packages/setuptools/config.py", line 430, in _parse_version
#15 2.878 version = self._parse_attr(value)
#15 2.878 File "/usr/lib/python3/dist-packages/setuptools/config.py", line 305, in _parse_attr
#15 2.878 module = import_module(module_name)
#15 2.878 File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
#15 2.878 return _bootstrap._gcd_import(name[level:], package, level)
#15 2.878 File "", line 994, in _gcd_import
#15 2.878 File "", line 971, in _find_and_load
#15 2.878 File "", line 953, in _find_and_load_unlocked
#15 2.878 ModuleNotFoundError: No module named 'markupsafe'

The error seems to be related to be related to this issue in the markupsafe repo. As suggested in the issue, it is resolved by updating pip.

Hence, I suggest updating pip in the dockerfile with something like
RUN pip3 install --upgrade pip

La geolocalización no me corre

Buenas noches, estuve mirando su repositorio y la geolocalización me falló. Ejecute todos los comandos para que me mostrará los puntos de servicio, pero se me ha hecho difícil, no se si podrían ayudarme a resolver el problema o decirme porque no se ejecuta correctamente.
Gracias por su atención.

Python app can not connect to DataSF

App.py failes to connect to http://data.sfgov.org/resource/rqzj-sfat.json and quits with error message

Traceback (most recent call last):
File "app.py", line 121, in
check_and_load_index()
File "app.py", line 43, in check_and_load_index
load_data_in_es()
File "app.py", line 15, in load_data_in_es
r = requests.get(url)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 423, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='data.sfgov.org', port=80): Max retries exceeded with url: /resource/rqzj-sfat.json (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7ff546c74350>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

I run the container on Docker Toolbox on Windows 10. I a browser I can access the url and get a json object.

Containter create in wrong order

When I run setup-docker.sh on my local machine elasticsearch containter does not have enought time to initialize, so when app failed to connect to elasticsearch containter, app is drop down.
To resolve this issue I add "sleep 10s" command between containers creating.

docker build fails

I am getting this error after following the excellent tutorial at - http://prakhar.me/docker-curriculum/
Thanks for posting the guide btw ! Error follows -

---> 038991bef88d
Removing intermediate container 6f941a872fa0
Step 10 : RUN npm run build
---> Running in 0f4d249d7776

[email protected] build /opt/flask-app
NODE_ENV='production' webpack -p

webpack 1.12.11
Usage: https://webpack.github.io/docs/cli.html

Options:
--help, -h, -?
--config
--context
--entry
--module-bind
--module-bind-post
--module-bind-pre
--output-path
--output-file
--output-chunk-file
--output-named-chunk-file
--output-source-map-file
--output-public-path
--output-jsonp-function
--output-pathinfo
--output-library
--output-library-target
--records-input-path
--records-output-path
--records-path
--define
--target
--cache [default: true]
--watch, -w
--watch which closes when stdin ends
--watch-aggregate-timeout
--watch-poll
--hot
--debug
--devtool
--progress
--resolve-alias
--resolve-loader-alias
--optimize-max-chunks
--optimize-min-chunk-size
--optimize-minimize
--optimize-occurence-order
--optimize-dedupe
--prefetch
--provide
--labeled-modules
--plugin
--bail
--profile
-d shortcut for --debug --devtool sourcemap --output-pathinfo
-p shortcut for --optimize-minimize
--json, -j
--colors, -c
--sort-modules-by
--sort-chunks-by
--sort-assets-by
--hide-modules
--display-exclude
--display-modules
--display-chunks
--display-error-details
--display-origins
--display-cached
--display-cached-assets
--display-reasons, --verbose, -v

Output filename not configured.
npm ERR! weird error 255
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0
The command '/bin/sh -c npm run build' returned a non-zero code: 1

docker build **was** failing

Hi.
Firstly, AWESOME overview at docker-curriculum.com ... very methodical and understandable ... thank you :-)
Just a quick FYI if anyone else hits this issue.
The docker build step was failing for me with E: Unable to locate package python-pip.
It turns out the fix was simply to remove the -yqq from the apt-get update step, thus:

RUN apt-get update

Cheers

Docker Compose - Containers not connecting

Running docker-compose up on both osx and ubuntu 16.04 I get this -

web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Out of retries. Bailing out...
foodtrucks_web_1 exited with code 1

I'm using the docker-compose.yml in this repo.

Web container cannot contact es using docker-compose

The problem is that a name for ES is created automatically (foodtrucks_es_1) and the network (foodtrucks_default). However, the app.py refers to host (es) which doesn't exist. Is there to have the docker-compose script set this as an environment parameter that gets populated in the container at launch time and picked up by app.py?

docker-compose up fails because elasticsearch does not spin up in time

The issue, as far as I can see it, is that on my machine, the es instance does not spin up in 15s(3 retries x 5s from the web service). This causes the web box to exit prematurely. I worked around this by using the wait-for-it script and modifying docker-compose to match. The workarond, in summary:

  1. Download wait-for-it.sh file into the flask-app directory
  2. Replace command: python app.py with command: ["./wait-for-it.sh", "es:9200", "--", "python", "app.py"]
  3. Run docker build -t <username>/foodtrucks . to update the image
  4. Re-run docker-compose up

This is probably not the best way to do it but I thought I'd record it here in case anyone else has the same issues.

Another obvious solution is simply to increase the timeout. Happy to make a pull request for either.

Docker-compose fails

I get this error, the flask app could not conetc to ElasticSearch app:

"""
pyright (c) 2018 Elasticsearch BV
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Out of retries. Bailing out...
es | [2020-11-09T00:47:36,762][INFO ][o.e.d.DiscoveryModule ] [ubZeIip] using discovery type [single-node]
foodtrucks_web_1 exited with code 1
es | [2020-11-09T00:47:38,699][INFO ][o.e.n.Node ] [ubZeIip] initialized
"""

Error with docker-compose

Same issue as AgustinPardo and jscalderon65 are reporting:

web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Unable to connect to ES. Retrying in 5 secs...
web_1 | Out of retries. Bailing out...
web_1 | /usr/local/lib/python3.6/dist-packages/requests/init.py:91: RequestsDependencyWarning: urllib3 (1.26.4) or chardet (3.0.4) doesn't match a supported version!
web_1 | RequestsDependencyWarning)

I have also tried to watch the creation through Portainer logs and am seeing this error:

python3: can't open file 'app.py': [Errno 2] No such file or directory

docker-compose.yml
version: "3"
services:
es:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
container_name: es
environment:
- discovery.type=single-node
ports:
- 9200:9200
volumes:
- esdata1:/usr/share/elasticsearch/data
web:
image: bfager27/foodtrucks-web
command: python3 app.py
depends_on:
- es
ports:
- 5000:5000
volumes:
- ./flask-app:/opt/flask-app
volumes:
esdata1:
driver: local

Dockerfile:
//# start from base
FROM ubuntu:18.04

LABEL maintainer="Prakhar Srivastav [email protected]"

//# install system-wide deps for python and node
RUN apt-get -yqq update
RUN apt-get -yqq install python3-pip python3-dev curl gnupg
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash
RUN apt-get install -yq nodejs

//# copy our application code
ADD flask-app /opt/flask-app
WORKDIR /opt/flask-app

//# fetch app specific deps
RUN npm install
RUN npm run build
RUN pip3 install -r requirements.txt

//# expose port
EXPOSE 5000

//# start app
CMD [ "python3", "./app.py" ]

web app doesn't work

Hello! I have this problem, the web app it is not shown in my browser and I do not know how to fix it, maybe docker-compose fails or the connection whit elasticsearch, If you know how to solve it I would appreciate your help.

elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7fe30b690390>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7fe30b690390>: Failed to establish a new connection: [Errno 111] Connection refused)
/usr/local/lib/python3.6/dist-packages/requests/init.py:91: RequestsDependencyWarning: urllib3 (1.26.3) or chardet (3.0.4) doesn't match a supported version!
RequestsDependencyWarning)
Unable to connect to ES. Retrying in 5 secs...
Unable to connect to ES. Retrying in 5 secs...
Unable to connect to ES. Retrying in 5 secs...
Out of retries. Bailing out...

Map works with Firefox, but failed with Chrome

Running Chrome Version 48.0.2564.82 (64-bit) on Ubuntu, map failed to load with the following messages:

Failed to initialize WebGLutil.extend._setupPainter @ map.js:674module.exports @ map.js:92(anonymous function) @ app.js:8t @ bootstrap 4f1375e74b4947f995c4:19(anonymous function) @ bootstrap 4f1375e74b4947f995c4:39(anonymous function) @ bootstrap 4f1375e74b4947f995c4:39
map.js:254Uncaught TypeError: Cannot read property 'resize' of undefined

While on Firefox, it looks fine. Maybe it comes from the map library you used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.