Dockerfile config
All checks were successful
gitea/minesweeper-frontend/pipeline/head This commit looks good

This commit is contained in:
Jose134 2025-01-21 23:58:02 +01:00
parent 816a76dcfa
commit 2c10b5f396
5 changed files with 50 additions and 39 deletions

View File

@ -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;"]
ENTRYPOINT ["npm", "run", "dev", "--", "--port=5713", "--host=0.0.0.0"]

41
Jenkinsfile vendored Normal file
View File

@ -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
"""
}
}
}
}

View File

@ -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;
}
}
}

View File

@ -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'],

View File

@ -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"
})