Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Andrés Baamonde Lozano
Andrés Baamonde Lozano

Posted on

     

Dockerizing your flask application

First we run our flask app into a apache server, so we need to configure apache server. A full tutorial can be checkedhere

wsgi file

#!/usr/bin/pythonimportsysimportlogginglogging.basicConfig(stream=sys.stderr)sys.path.insert(0,"/var/www/")fromsrc.runimportappasapplication
Enter fullscreen modeExit fullscreen mode

App python

importsyssys.path.insert(0,"/var/www/")fromapp.applicationimportExampleApifromconfigimportConfigurationcfg=Configuration(debug=False)app=ExampleApi(cfg)if__name__=="__main__":app.run(host=cfg.host,port=cfg.port,debug=cfg.debug)
Enter fullscreen modeExit fullscreen mode

Dockerfile

FROM ubuntu:12.04MAINTAINER Andrés Baamonde LozanoRUNapt-get update&& apt-getinstall-y apache2 libapache2-mod-wsgi python-dev python-pip&& apt-get clean&&rm-rf /var/lib/apt/lists/*RUNpipinstallFlask#enable mod_wsgiRUNa2dissite defaultRUNa2dissite default-sslRUNa2enmod wsgiENV APACHE_RUN_USER www-dataENV APACHE_RUN_GROUP www-dataENV APACHE_LOG_DIR /var/log/apache2COPY src /var/www/src#Creamos el virtual hostCOPY resources/docker/app /etc/apache2/sites-available/appflaskRUNchown-R www-data:www-data /var/www/srcRUNchownwww-data:www-data /etc/apache2/sites-available/appflaskRUNa2ensite appflaskEXPOSE 80CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
Enter fullscreen modeExit fullscreen mode

You can check full application at mygithub

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Bohemian Developer
  • Location
    A coruña
  • Joined

More fromAndrés Baamonde Lozano

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp