Multiple Questions on Docker Setup for Spring Boot and Angular: Container Naming, Access...

Discussão em 'Angular' iniciado por Broken Dust, Dezembro 19, 2024.

  1. Broken Dust

    Broken Dust Guest

    In preparation for a new job, I wanted to familiarize myself with the new working conditions. It's been a while since I last used Dockerfiles and docker-compose.yml.

    You can see my file structure below my questions. I haven't written anything except the 'Hello World!' and the init.sql. Only the standard Spring Boot and Angular code is running so far.

    At least I managed to get my containers running, but I have a few questions about it and hope that someone can answer them for me:

    1. Why do the names of my containers start with 'src'?

    [​IMG]


    1. How can I change this naming?


    2. Why can I only access my Angular/TypeScript application in the container if I call the URL http://localhost/browser/index.html?

    [​IMG]

    1. Why is nothing displayed there except 'Hello World!'?

    [​IMG]


    1. How can I change this?


    2. How can I get a live reload to be done when I make changes to the Angular/TypeScript application?


    3. Is the way I wrote my Dockerfiles and docker-compose good, or should I combine them into one big file?


    4. And why the flying fart do I have the package-lock.json in my root directory?


    5. What else can I do for better structure and functionality?

    I hope that someone of you can answer at least one of my questions.

    My file structure:

    [​IMG]

    Content of my docker-compose.yml:

    services:
    aix-pulse-db:
    build:
    context: ./main/persistence
    dockerfile: ./docker/Dockerfile
    environment:
    POSTGRES_USER: postgres
    POSTGRES_PASSWORD: postgres
    POSTGRES_DB: aix-pulseDB
    volumes:
    - aix-pulse-db-data:/var/lib/postgresql/data
    ports:
    - "5432:5432"

    backend:
    build:
    context: ../
    dockerfile: ./src/main/java/docker/Dockerfile
    ports:
    - "8080:8080"
    depends_on:
    - aix-pulse-db

    frontend:
    build:
    context: ./main/angular/aix-pulse-frontend
    dockerfile: ../docker/Dockerfile
    ports:
    - "80:80"

    volumes:
    aix-pulse-db-data:


    Content angular/docker/Dockerfile:

    FROM node:22.12.0 AS builder
    WORKDIR /app
    COPY package*.json ./
    RUN npm install
    COPY . .
    RUN npm run build --prod

    FROM nginx:alpine
    COPY --from=builder /app/dist/aix-pulse-frontend /usr/share/nginx/html
    EXPOSE 80
    CMD ["nginx", "-g", "daemon off;"]


    Content java/docker/Dockerfile:

    FROM eclipse-temurin:17-jre
    WORKDIR /app
    COPY target/aix-pulse.jar app.jar
    ENTRYPOINT ["java", "-jar", "app.jar"]
    EXPOSE 8080


    Content persistence/docker/Dockerfile:

    FROM postgres:15
    ENV POSTGRES_USER=postgres
    ENV POSTGRES_PASSWORD=postgres
    ENV POSTGRES_DB=aix-pulseDB
    COPY init.sql /docker-entrypoint-initdb.d/
    EXPOSE 5432


    Thanks in advance.

    Continue reading...

Compartilhe esta Página