Error with deployment in shared server of angular with docker

Viewed 28

I have a problem with the deployment of my angular code with docker in a shared server.

This is my docker-compose.yaml

# This file will use the Dockerfile to run a container with that image

version: "3.3"
services:
  web:
    # build: . will make Docker Compose run 'docker image build .'
    # https://stackoverflow.com/questions/29480099/whats-the-difference-between-docker-compose-vs-dockerfile
    build:
      context: .
      dockerfile: Dockerfile
    image: test/angular
    
  #Nginx Service
  nginx-web:
    image: nginx:alpine
    container_name: nginx-web
    restart: always
    tty: true
    ports:
      - 443:443
      - 80:80
    networks:
      - app-network
    volumes:
      - ./docker-configs/nginx/conf.d:/etc/nginx/conf.d
      - ./docker-configs/nginx/ssl/:/etc/ssl/

    # If we wanted more services, we'll put them right here
    #redis:
    #image: "redis:alpine"
#Docker Networks
networks:
  app-network:
    driver: bridge

my Dockerfile

###############################################################################
# Stage 1: Compile and Build angular codebase
###############################################################################
# Use official node image as the base image
FROM node:16.0-alpine as node

# Set the working directory
WORKDIR /app

# Add the source code to app
COPY . /app

# Install all the dependencies
RUN npm install

# Generate the build of the application
RUN npm run build

# Stage 2: Serve app with nginx server

# Use official nginx image as the base image
FROM nginx:latest


RUN apt update
RUN apt install vim libgpm2 vim-common vim-runtime xxd gpm vim-doc vim-scripts


# Copy the build output to replace the default nginx contents.
COPY --from=node /app/dist/web /usr/share/nginx/html

COPY /docker-configs/nginx/conf.d/nginx-custom.conf /etc/nginx/conf.d/default.conf

# Expose port 80
EXPOSE 80

and this is my nginx-custom.conf

server {
    listen 80;
    listen 443 ssl;
    server_name test-angular.eu;
    ssl_certificate     /etc/ssl/domain.tld.chained.crt;
    ssl_certificate_key /etc/ssl/domain.tld.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers         HIGH:!aNULL:!MD5; 
    
    root  /usr/share/nginx/html;
    index index.html;

    location / {
      try_files $uri $uri/ /index.html =404;
    }
}

after i run docker-compose up, the page test-angular.eu is not accessible. But when i go to ip of my server, nginx is working.

What am I doing wrong?

Thank you to everyone.

0 Answers
Related