diff --git a/Dockerfile b/Dockerfile index 627cd28..c78d763 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,13 @@ -# Use an official node image as the base image -FROM node:20-alpine as build +FROM node:23-alpine -# Set the working directory -WORKDIR /app +WORKDIR /usr/src/app -# Copy package.json and package-lock.json -COPY package.json package-lock.json ./ +COPY package*.json ./ -# Install dependencies RUN npm install -# Copy the rest of the application code COPY . . -# Build the application -RUN npm run build +EXPOSE 5713 -# Use an official nginx image to serve the app -FROM nginx:alpine - -# Copy the build output to the nginx html directory -COPY --from=build /app/dist /usr/share/nginx/html - -# Copy nginx configuration file -COPY nginx.conf /etc/nginx/conf.d/default.conf - -# Expose port 80 -EXPOSE 80 - -# Start nginx -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +ENTRYPOINT ["npm", "run", "dev", "--", "--port=5713", "--host=0.0.0.0"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..1821201 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,41 @@ +pipeline { + agent any + + environment { + IMAGE_NAME = "darkbird/minesweeper-frontend:latest" + REGISTRY_IMAGE_NAME = "registry.xdarkbird.duckdns.org/darkbird/minesweeper-frontend:latest" + } + + stages { + stage('Docker build') { + steps { + sh """ + docker build --network="host" -t ${IMAGE_NAME} . + """ + } + } + stage('Docker tag') { + steps { + sh """ + docker image tag ${IMAGE_NAME} ${REGISTRY_IMAGE_NAME} + """ + } + } + stage('Docker push') { + steps { + sh """ + docker push ${REGISTRY_IMAGE_NAME} + """ + } + } + stage('Docker clean') { + steps { + sh """ + docker rmi ${IMAGE_NAME} + docker rmi ${REGISTRY_IMAGE_NAME} + docker image prune -f + """ + } + } + } +} diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index 8282623..0000000 --- a/nginx.conf +++ /dev/null @@ -1,14 +0,0 @@ -server { - listen 80; - server_name localhost; - - location / { - add_header "Access-Control-Allow-Origin" "*"; - add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, PUT, DELETE"; - add_header "Access-Control-Allow-Headers" "Origin, X-Requested-With, Content-Type, Accept, Authorization"; - - if ($request_method = OPTIONS) { - return 204; - } - } -} \ No newline at end of file diff --git a/src/socket.js b/src/socket.js index b10a1f5..71444d3 100644 --- a/src/socket.js +++ b/src/socket.js @@ -1,7 +1,7 @@ import process from 'process'; import { io } from 'socket.io-client'; -const URL = process.env.BACKEND_URL || 'http://localhost:3001'; +const URL = process.env.BACKEND_URL || 'http://localhost:5174'; export const socket = io(URL, { autoConnect: false, transports: ['websocket'], diff --git a/vite.config.js b/vite.config.js index 8e47809..a6c5ac1 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,5 +4,8 @@ import react from '@vitejs/plugin-react' // https://vite.dev/config/ export default defineConfig({ plugins: [react()], + server: { + host: true + }, base: "http://localhost:5173" })