I have a very similar question as this one.
I do have an Angular application that collects data which are then processed via a REST Api. I can happily dockerize both applications and they run fine locally, however, when I try deploy them to make them accessible from "everywhere" I can only reach the front end, but the connection to REST Api is not functional.
Inside my Angular app, I have a file baseurl.ts. That just contains:
export const baseURL = 'http://localhost:3000/';
I make the application production ready using:
ng build --prod
which creates the dist folder and then the following docker container (taken from here):
FROM node:alpine AS builder
ARG PROXY=http://myproxy
ARG NOPROXY=localhost,127.0.0.1
ENV http_proxy=${PROXY}
ENV https_proxy=${PROXY}
ENV NO_PROXY=${NOPROXY}
ENV no_proxy=${NOPROXY}
WORKDIR /app
COPY . .
RUN npm install && \
npm run build
FROM nginx:alpine
COPY --from=builder /app/dist/* /usr/share/nginx/html/
I build the container using
docker build -t form_angular:v1
and run it using
docker run -d -p8088:80 form_angular:v1
The second Dockerfile for the REST Api looks like this:
FROM continuumio/miniconda3
ARG PROXY=http://myproxy
ARG NOPROXY=localhost,127.0.0.1
ENV http_proxy=${PROXY}
ENV https_proxy=${PROXY}
ENV NO_PROXY=${NOPROXY}
ENV no_proxy=${NOPROXY}
COPY my_environment.yml my_environment.yml
SHELL ["/bin/bash", "-c"]
RUN echo "Using proxy $PROXY" \
&& touch /etc/apt/apt.conf \
&& echo "Acquire::http::Proxy \"$PROXY\";" >> /etc/apt/apt.conf \
&& cat /etc/apt/apt.conf \
&& apt-get -q -y update \
&& DEBIAN_FRONTEND=noninteractive apt-get -q -y upgrade \
&& apt-get -q -y install \
build-essential \
&& apt-get -q clean \
&& rm -rf /var/lib/apt/lists/*
RUN ["conda", "env", "create", "-f", "my_environment.yml"]
COPY user_feedback.py user_feedback.py
CMD source activate my_environment; gunicorn -b 0.0.0.0:3000 user_feedback:app
Building:
docker build -t form_rest:latest .
Running:
docker run --name form_rest -d -p 3000:3000
As I said, that all works as expected when running on the localhost. How do I now make these two containers talk to each other for "global" deployment?