Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Serve static assets from the app itself
Since they will be embedded in the app image, we want the app to always
serve these, not the proxy.

Static assets are moving from this model:

                                                    serve static asset
                                                    ^
                                                    |
    compiled assets volume - (read static asset) -> proxy (nginx)

To this model:

    serve static asset
    ^
    |
    proxy (nginx)
    ^
    |
    (proxy request)
    |
    app (embeds static assets)

We are making the app available on http://localhost:4000 so that devs
can keep the same development workflow.

Proxy is still available on http://localhost, even though static assets
are not being proxied correctly due to Access-Control-Allow-Origin.
Planning on addressing it via
https://medium.com/@yagoazedias_75857/how-to-configure-cors-in-your-phoenix-application-5ef0234bc25f

[#158222089]
  • Loading branch information
gerhard committed Oct 9, 2018
1 parent 9247b44 commit c272fb1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -53,7 +53,7 @@ app_1 | Webpack is watching the files…
...
```

You can access a dev copy of changelog.com locally, at http://localhost
You can access a dev copy of changelog.com locally, at http://localhost:4000

Since the app database will be completely empty, you might want to seed it by running the following command: `docker-compose run app mix run priv/repo/seeds.exs`.
This command resets the app database, please only run it if you are OK losing all data in the app database.
Expand Down
2 changes: 1 addition & 1 deletion config/dev.exs
Expand Up @@ -8,7 +8,7 @@ use Mix.Config
# with brunch.io to recompile .js and .css sources.
config :changelog, ChangelogWeb.Endpoint,
http: [port: 4000],
static_url: [host: "localhost", port: 80],
static_url: [host: "localhost", port: 4000],
debug_errors: true,
code_reloader: true,
cache_static_lookup: false,
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yml
Expand Up @@ -16,8 +16,8 @@ services:
environment:
DB_URL: "ecto://postgres@db:5432/changelog_dev"
VIRTUAL_HOST: "localhost"
expose:
- "4000"
ports:
- "4000:4000"
volumes:
- ./assets/admin/:/app/assets/admin/
- ./assets/app/:/app/assets/app/
Expand Down Expand Up @@ -47,7 +47,6 @@ services:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./nginx/vhost.d:/etc/nginx/vhost.d:ro
- ./nginx/conf.d/changelog.conf:/etc/nginx/conf.d/changelog.conf:ro
- ./priv/static/:/var/www/static:ro
- ./priv/uploads/:/var/www/uploads:ro

volumes:
Expand Down
3 changes: 0 additions & 3 deletions nginx/vhost.d/default
Expand Up @@ -13,9 +13,6 @@ proxy_max_temp_file_size 0;
# http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size
client_max_body_size 200M;

# Static assets compiled by webpack will be available here
root /var/www/static;

location ^~ /uploads {
root /var/www;

Expand Down

0 comments on commit c272fb1

Please sign in to comment.