Fix deployment
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
9e20fe6829
commit
63f2d69430
@ -1,13 +1,13 @@
|
||||
FROM node:20-alpine as builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
ARG VITE_APP_BACKEND_ADDRESS
|
||||
ENV VITE_APP_BACKEND_ADDRESS $VITE_APP_BACKEND_ADDRESS
|
||||
ARG VITE_SOCKET_URL
|
||||
ENV VITE_SOCKET_URL $VITE_SOCKET_URL
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
|
||||
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
|
||||
EXPOSE 5173
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
3
Jenkinsfile
vendored
3
Jenkinsfile
vendored
@ -4,13 +4,14 @@ pipeline {
|
||||
environment {
|
||||
IMAGE_NAME = "darkbird/minesweeper-frontend:latest"
|
||||
REGISTRY_IMAGE_NAME = "registry.xdarkbird.duckdns.org/darkbird/minesweeper-frontend:latest"
|
||||
VITE_SOCKET_URL = "http://darkbird.es:5174"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Docker build') {
|
||||
steps {
|
||||
sh """
|
||||
docker build --build-arg VITE_SOCKET_URL=http://minesweeper-backend.darkbird.es --network="host" -t ${IMAGE_NAME} .
|
||||
docker build --build-arg VITE_SOCKET_URL=${VITE_SOCKET_URL} --network="host" -t ${IMAGE_NAME} .
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Minesweeper</title>
|
||||
</head>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
server {
|
||||
listen 3000;
|
||||
listen 5173;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
etag on;
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.jsx'
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
|
||||
@ -1,56 +1,56 @@
|
||||
import { io } from 'socket.io-client';
|
||||
import { io } from "socket.io-client";
|
||||
|
||||
const URL = 'http://192.168.0.134:5174';
|
||||
console.log('Backend URL', URL);
|
||||
const URL = import.meta.env.VITE_SOCKET_URL || "http://192.168.0.134:5174";
|
||||
console.log("Backend URL", URL);
|
||||
export const socket = io(URL, {
|
||||
autoConnect: false,
|
||||
transports: ['websocket'],
|
||||
transports: ["websocket"],
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
export const setupSocketEffect = (socket, setRoom) => {
|
||||
const socketHandlers = [
|
||||
{
|
||||
event: 'connect',
|
||||
event: "connect",
|
||||
handler: () => {
|
||||
}
|
||||
},
|
||||
{
|
||||
event: 'disconnect',
|
||||
event: "disconnect",
|
||||
handler: () => {
|
||||
setRoom(null);
|
||||
}
|
||||
},
|
||||
{
|
||||
event: 'error',
|
||||
event: "error",
|
||||
handler: (error) => {
|
||||
console.error(error);
|
||||
console.error("Socket error", error);
|
||||
}
|
||||
},
|
||||
{
|
||||
event: 'youJoinedRoom',
|
||||
event: "youJoinedRoom",
|
||||
handler: (data) => {
|
||||
setRoom({ ...data });
|
||||
}
|
||||
},
|
||||
{
|
||||
event: 'roomUserJoined',
|
||||
event: "roomUserJoined",
|
||||
handler: (data) => {
|
||||
setRoom({ ...data });
|
||||
}
|
||||
},
|
||||
{
|
||||
event: 'roomUserLeft',
|
||||
event: "roomUserLeft",
|
||||
handler: (data) => {
|
||||
setRoom({ ...data });
|
||||
}
|
||||
},
|
||||
{
|
||||
event: 'updateRoom',
|
||||
event: "updateRoom",
|
||||
handler: (data) => {
|
||||
setRoom({ ...data });
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
socketHandlers.forEach(({ event, handler }) => {
|
||||
|
||||
@ -7,7 +7,7 @@ export default defineConfig(({ command, mode }) => {
|
||||
return {
|
||||
plugins: [react()],
|
||||
server: {
|
||||
port: 3000,
|
||||
port: 5173,
|
||||
host: true,
|
||||
watch: {
|
||||
usePolling: true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user