-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (35 loc) · 1.61 KB
/
Dockerfile
File metadata and controls
47 lines (35 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# syntax=docker/dockerfile:1
# Optimized Dockerfile for polari-platform-angular
# Uses layer caching to speed up rebuilds when only source code changes
FROM node:20
WORKDIR /project
# Install Angular CLI globally (cached layer - rarely changes)
RUN npm install -g @angular/cli@19.2.0
# Copy package files FIRST for better caching
# This layer only rebuilds when package.json or package-lock.json changes
COPY package*.json ./
# Install dependencies (using npm install to handle lock file version differences)
RUN --mount=type=cache,target=/root/.npm \
npm install
# Copy source code LAST (this invalidates cache most often)
# Separating this from dependencies ensures npm packages are cached
COPY . .
# Pre-build the application during image creation
# This makes container startup faster and catches build errors early
RUN ng build --configuration=development
# WARNING: This exposes the port strictly to other containers on the same network
# This DOES NOT expose the application on the localhost of the HOST machine
# Only the mapping in docker-compose or using the -p flag will expose to host
#
# ALSO: Make certain your app uses --host 0.0.0.0 to expose it externally
# Mapping externally on the virtual network allows docker-compose or -p mapping
# to expose the port on the host, otherwise it will be unavailable
# Expose HTTP and HTTPS ports
# HTTP: 4200, HTTPS: 2087 (Cloudflare-compatible)
EXPOSE 4200
EXPOSE 2087
# Make entrypoint executable
RUN chmod +x /project/entrypoint.sh
# Use entrypoint script for dual HTTP/HTTPS support
# Falls back to HTTP-only if SSL certificates are not available
CMD ["/project/entrypoint.sh"]