Skip to content

Commit

Permalink
feat: optimize build process & switch to nginx container (#20)
Browse files Browse the repository at this point in the history
This fixes the CORS issue when running the container in prod as well.
The API URL is currently specified in multiple places.
Added vite optimize to the build script.

fixes #18
  • Loading branch information
laurigates authored Aug 23, 2024
1 parent 49f3649 commit 0442a83
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:21-alpine
FROM node:21-alpine as build

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-and-push

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

WORKDIR /app

COPY . .
RUN npm install
RUN npx vite build
RUN npx vite optimize
RUN npm ci
RUN npm run build

EXPOSE 4173
FROM nginx:latest

CMD [ "npx", "vite", "preview" ]
COPY --from=build /app/dist/ /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
4 changes: 2 additions & 2 deletions cesium-dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
- name: cesium-dashboard
image: ghcr.io/forumviriumhelsinki/cesium-dashboard:latest
ports:
- containerPort: 4173
- containerPort: 80
---
apiVersion: v1
kind: Service
Expand All @@ -27,7 +27,7 @@ spec:
ports:
- name: http
port: 80
targetPort: 4173
targetPort: 80
selector:
app: cesium-dashboard
---
Expand Down
14 changes: 14 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server {
listen 80;
server_name _;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri /index.html;
}
location /tiles {
proxy_pass "https://dl2sa.blob.core.windows.net/public3d/katukuntotieto";
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"build": "vue-tsc && vite build && vite optimize",
"deploy": "vue-tsc && vite build && aws s3 sync dist s3://hel-roadcondition --acl public-read --profile advianconsulting",
"preview": "vite preview --host"
},
Expand Down

0 comments on commit 0442a83

Please sign in to comment.