I am absolute beginner to docker. trying to dockerize my app. running in couple of issues. I have setup my Dockerfile so angular app build for using ng build
. But of course the container exit after transpiling. well, I need it to listen for the code changes and transpile again. I thought ng serve
would help me to achieve the desired functionality. Unfortunately, it hangs in ng serve
step while trying to build the image using docker-compose build
.
Angular Dockerfile
FROM node:9
ADD package.json /tmp/package.json
RUN cd /tmp && npm install
RUN mkdir -p /app && cp -a /tmp/node_modules /app
WORKDIR /app
ADD . /app
# build application
RUN npm run build
nginx DockerFile
FROM tutum/nginx
RUN rm /etc/nginx/sites-enabled/default
ADD sites-enabled/ /etc/nginx/sites-enabled
nginx configuratioins
server {
listen 80;
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 256;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /app/dist;
location / {
try_files $uri $uri/ /index.html =404;
}
docker-compose.yml
version: "3.3"
services:
nginx:
build:
context: ./nginx
ports:
- 8080:80
volumes:
- app:/app
- ./:/app
client:
build:
context: ./client
volumes:
- app:/app
volumes:
app:
when I hit localhost:8080. I can see the first page.
any help is fully appreciated. thanks