Skip to content

Commit 093d80d

Browse files
fix: nginx route rewrites (#55)
Co-authored-by: Krieger Dario <dario.krieger@icloud.com>
1 parent f11e1dc commit 093d80d

2 files changed

Lines changed: 47 additions & 35 deletions

File tree

src/frontend/Dockerfile

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
1-
# Stage 1: Build the application
2-
FROM node:20-alpine AS build
3-
4-
# Set working directory inside container
5-
WORKDIR /app
6-
7-
# Copy package files first for better caching
8-
COPY package.json yarn.lock ./
9-
10-
# Install dependencies with Yarn
11-
RUN yarn install
12-
13-
# Copy the rest of the application code
14-
COPY . .
15-
16-
# Build the Vue.js application
17-
RUN yarn build
18-
19-
20-
# Stage 2: Serve with a lightweight web server
21-
FROM nginx:alpine
22-
23-
# Copy built files from previous stage
24-
COPY --from=build /app/dist /usr/share/nginx/html
25-
26-
# Copy custom nginx config (optional)
27-
# e.g., handles Vue router history mode
28-
# Uncomment if you create nginx.conf
29-
# COPY nginx.conf /etc/nginx/conf.d/default.conf
30-
31-
# Expose port 80
32-
EXPOSE 80
33-
34-
# Start nginx server
35-
CMD ["nginx", "-g", "daemon off;"]
1+
# Stage 1: Build the application
2+
FROM node:20-alpine AS build
3+
4+
# Set working directory inside container
5+
WORKDIR /app
6+
7+
# Copy package files first for better caching
8+
COPY package.json yarn.lock ./
9+
10+
# Install dependencies with Yarn
11+
RUN yarn install
12+
13+
# Copy the rest of the application code
14+
COPY . .
15+
16+
# Build the Vue.js application
17+
RUN yarn build
18+
19+
20+
# Stage 2: Serve with a lightweight web server
21+
FROM nginx:alpine
22+
23+
# Copy built files from previous stage
24+
COPY --from=build /app/dist /usr/share/nginx/html
25+
26+
# Copy custom nginx config
27+
# e.g., handles Vue router history mode
28+
COPY nginx.conf /etc/nginx/conf.d/default.conf
29+
30+
# Expose port 80
31+
EXPOSE 80
32+
33+
# Start nginx server
34+
CMD ["nginx", "-g", "daemon off;"]

src/frontend/nginx.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
8+
location / {
9+
try_files $uri $uri/ /index.html;
10+
}
11+
12+
error_page 404 /index.html;
13+
}

0 commit comments

Comments
 (0)