mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
feat: add frontend nginx image
This commit is contained in:
1 parent
fcaa088a31
commit
e54ae32960
6 files changed
+50
-6
No files matched your search
+3
-2
@@ -1,2 +1,3 @@
|
|||||||
node_modules
|
*/node_modules
|
||||||
.git
|
.git
|
||||||
|
*/dist
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM node as build-stage
|
||||||
|
WORKDIR /app
|
||||||
|
COPY app/package.json yarn.lock ./
|
||||||
|
RUN yarn install
|
||||||
|
COPY app .
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
# Production stage
|
||||||
|
FROM nginx:stable-alpine as production-stage
|
||||||
|
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||||
|
COPY deployment/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: '/api',
|
baseURL: '/api/v1',
|
||||||
})
|
})
|
||||||
|
|
||||||
export default api
|
export default api
|
||||||
+1
-2
@@ -7,9 +7,8 @@ export default defineConfig({
|
|||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: `${process.env.API_TARGET || 'http://localhost:3000'}/api/v1`,
|
target: process.env.API_TARGET || 'http://localhost:3000',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
||||||
},
|
},
|
||||||
'/socket.io': {
|
'/socket.io': {
|
||||||
target: process.env.API_TARGET || 'ws://localhost:3000',
|
target: process.env.API_TARGET || 'ws://localhost:3000',
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://backend:3000;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /socket.io/ {
|
||||||
|
proxy_pass http://backend:3000;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-1
@@ -1,11 +1,20 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
|
image: lancatlin/linux-odyssey:app
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: app/Dockerfile
|
||||||
|
networks:
|
||||||
|
internal:
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
backend:
|
||||||
image: lancatlin/linux-odyssey
|
image: lancatlin/linux-odyssey
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: server/Dockerfile
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
- players
|
- players
|
||||||
|
|||||||
Reference in new issue
Block a user