Skip to content

Commit 2c0c800

Browse files
troke12cursoragent
andcommitted
Fix: normalize frontend entrypoint/template line endings for Docker
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 27d7545 commit 2c0c800

File tree

4 files changed

+61
-56
lines changed

4 files changed

+61
-56
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* text=auto
2+
3+
# Ensure scripts/config templates stay LF (fixes /bin/sh^M issues)
4+
*.sh text eol=lf
5+
*.template text eol=lf
6+
*.conf text eol=lf

frontend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN apk add --no-cache gettext
1414
COPY --from=builder /app/dist /usr/share/nginx/html
1515
COPY nginx.conf.template /etc/nginx/templates/default.conf.template
1616
COPY docker-entrypoint.sh /docker-entrypoint.sh
17-
RUN chmod +x /docker-entrypoint.sh
17+
RUN sed -i 's/\r$//' /docker-entrypoint.sh /etc/nginx/templates/default.conf.template && chmod +x /docker-entrypoint.sh
1818
ENV BACKEND_UPSTREAM=backend:5000
1919
EXPOSE 80
2020
ENTRYPOINT ["/docker-entrypoint.sh"]

frontend/docker-entrypoint.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#!/bin/sh
2-
set -eu
3-
4-
# Default backend upstream inside docker-compose network.
5-
# Override this env var if your backend service name differs.
6-
: "${BACKEND_UPSTREAM:=backend:5000}"
7-
8-
envsubst '${BACKEND_UPSTREAM}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf
9-
10-
exec nginx -g 'daemon off;'
11-
1+
#!/bin/sh
2+
set -eu
3+
4+
# Default backend upstream inside docker-compose network.
5+
# Override this env var if your backend service name differs.
6+
: "${BACKEND_UPSTREAM:=backend:5000}"
7+
8+
envsubst '${BACKEND_UPSTREAM}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf
9+
10+
exec nginx -g 'daemon off;'
11+

frontend/nginx.conf.template

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
1-
server {
2-
listen 80;
3-
server_name localhost;
4-
root /usr/share/nginx/html;
5-
index index.html;
6-
7-
# Gzip compression
8-
gzip on;
9-
gzip_vary on;
10-
gzip_min_length 1024;
11-
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;
12-
13-
# SPA routing - serve index.html for all routes
14-
location / {
15-
try_files $uri $uri/ /index.html;
16-
}
17-
18-
# API proxy to backend service (set BACKEND_UPSTREAM at runtime)
19-
location /api {
20-
proxy_pass http://${BACKEND_UPSTREAM};
21-
proxy_http_version 1.1;
22-
proxy_set_header Upgrade $http_upgrade;
23-
proxy_set_header Connection 'upgrade';
24-
proxy_set_header Host $host;
25-
proxy_cache_bypass $http_upgrade;
26-
proxy_set_header X-Real-IP $remote_addr;
27-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28-
proxy_set_header X-Forwarded-Proto $scheme;
29-
}
30-
31-
# Docker registry API proxy
32-
location /v2 {
33-
proxy_pass http://${BACKEND_UPSTREAM};
34-
proxy_http_version 1.1;
35-
proxy_set_header Upgrade $http_upgrade;
36-
proxy_set_header Connection 'upgrade';
37-
proxy_set_header Host $host;
38-
proxy_cache_bypass $http_upgrade;
39-
proxy_set_header X-Real-IP $remote_addr;
40-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
41-
proxy_set_header X-Forwarded-Proto $scheme;
42-
}
43-
}
44-
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
root /usr/share/nginx/html;
5+
index index.html;
6+
7+
# Gzip compression
8+
gzip on;
9+
gzip_vary on;
10+
gzip_min_length 1024;
11+
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;
12+
13+
# SPA routing - serve index.html for all routes
14+
location / {
15+
try_files $uri $uri/ /index.html;
16+
}
17+
18+
# API proxy to backend service (set BACKEND_UPSTREAM at runtime)
19+
location /api {
20+
proxy_pass http://${BACKEND_UPSTREAM};
21+
proxy_http_version 1.1;
22+
proxy_set_header Upgrade $http_upgrade;
23+
proxy_set_header Connection 'upgrade';
24+
proxy_set_header Host $host;
25+
proxy_cache_bypass $http_upgrade;
26+
proxy_set_header X-Real-IP $remote_addr;
27+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28+
proxy_set_header X-Forwarded-Proto $scheme;
29+
}
30+
31+
# Docker registry API proxy
32+
location /v2 {
33+
proxy_pass http://${BACKEND_UPSTREAM};
34+
proxy_http_version 1.1;
35+
proxy_set_header Upgrade $http_upgrade;
36+
proxy_set_header Connection 'upgrade';
37+
proxy_set_header Host $host;
38+
proxy_cache_bypass $http_upgrade;
39+
proxy_set_header X-Real-IP $remote_addr;
40+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
41+
proxy_set_header X-Forwarded-Proto $scheme;
42+
}
43+
}

0 commit comments

Comments
 (0)