I have dockerized a backend webapp built with Flask. The CMD
line of the Dockerfile
runs python app.py
which internally calls app.run(host='0.0.0.0')
, so that the app is running (within the docker container) at 0.0.0.0:5000
. I then run the built container with
$ docker run -p 5000:5000 -it my-image:latest
The frontend is built with ember. Within the .ember-cli
file, proxy
is set to http://localhost:5000
. When I run $ ember serve
locally, the app runs smoothly at localhost:4200
, communicating with the backend running from the docker image. However, I also want to run the frontend on a docker image (based on an apache image). My Dockerfile:
FROM httpd:2.4-alpine
COPY ./dist/ /usr/local/apache2/htdocs/
COPY ./.htaccess /usr/local/apache2/htdocs/
The .htaccess
file is copied directly from Ember - Deploying (as per the Servers
section):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.html [L]
</IfModule>
I then do the following:
$ ember b --prod # build the app for production (stored in ./dist/)
$ docker build -t my-frontend:latest .
$ docker run -dit --name my-frontend -p 8080:80 my-frontend:latest
I then go to localhost:8080
, and can see my app's loading wheel, which means this image is working in isolation. However, I continue to get 404 errors when it tries to access the backend.
What am I doing wrong that the containers can't communicate with each other?
Aucun commentaire:
Enregistrer un commentaire