How to bundle an API server and static web client together?

Hi all,

I have a..

A. Web Client (Vue.js)

B. Web API Server (Node)

Dockerfiles and `docker-compose` for each. It works well 🙂

Now I want to deploy to say, a DigitalOcean instance. The DO instance has a public IP. And this is what the users will hit the application from. So, in development today for the "local" build on my machine I've been passing in the "VUE_APP_ENDPOINT" as "localhost:3000" to point to the API server on the same compose network. This works today since it can be reached on the host adapter. When deploying, this obviously wouldn't work. I can think of a couple solutions…

  1. Reverse Proxy like Traefik in front of both services — and have one of the paths, like `/api` aliased to the API server. Then, pass in `//api` as the endpoint
  2. From the CI tool / deployment script, pass in the hostname IP of the target

Is there a better way? 2 feels worse since it feels like it then has ties to the environment it runs in rather than

submitted by /u/vaughands
[link] [comments]
Source: Reddit