New vite config and dockerfile for prod
All checks were successful
gitea/minesweeper-frontend/pipeline/head This commit looks good
All checks were successful
gitea/minesweeper-frontend/pipeline/head This commit looks good
This commit is contained in:
parent
22ac242c29
commit
bd6fdf2a9e
22
Dockerfile
22
Dockerfile
@ -1,13 +1,13 @@
|
||||
FROM node:23-alpine
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
FROM node:20-alpine as builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
ARG VITE_APP_BACKEND_ADDRESS
|
||||
ENV VITE_APP_BACKEND_ADDRESS $VITE_APP_BACKEND_ADDRESS
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
|
||||
EXPOSE 5713
|
||||
|
||||
ENTRYPOINT ["npm", "run", "dev", "--", "--port=5173", "--host=0.0.0.0"]
|
||||
FROM nginx:1.25.4-alpine-slim as prod
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d
|
||||
EXPOSE 3000
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -10,7 +10,7 @@ pipeline {
|
||||
stage('Docker build') {
|
||||
steps {
|
||||
sh """
|
||||
docker build --network="host" -t ${IMAGE_NAME} .
|
||||
docker build --build-arg VITE_SOCKET_URL=http://minesweeper-backend.darkbird.es --network="host" -t ${IMAGE_NAME} .
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
15
nginx.conf
Normal file
15
nginx.conf
Normal file
@ -0,0 +1,15 @@
|
||||
server {
|
||||
listen 3000;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
etag on;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import { io } from 'socket.io-client';
|
||||
|
||||
const URL = 'http://minesweeper-backend.darkbird.es';
|
||||
const URL = import.meta.env.VITE_SOCKET_URL || 'http://localhost:5174';
|
||||
export const socket = io(URL, {
|
||||
autoConnect: false,
|
||||
transports: ['websocket'],
|
||||
|
||||
@ -1,11 +1,24 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import process from "process";
|
||||
import react from "@vitejs/plugin-react";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
const env = loadEnv(mode, process.cwd());
|
||||
return {
|
||||
plugins: [react()],
|
||||
server: {
|
||||
host: true
|
||||
port: 3000,
|
||||
host: true,
|
||||
watch: {
|
||||
usePolling: true,
|
||||
},
|
||||
base: "http://localhost:5173"
|
||||
})
|
||||
esbuild: {
|
||||
target: "esnext",
|
||||
platform: "linux",
|
||||
},
|
||||
},
|
||||
define: {
|
||||
VITE_SOCKET_URL: JSON.stringify(env.VITE_SOCKET_URL),
|
||||
},
|
||||
};
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user