diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..cb3ff94 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,25 @@ +name: Build and Deploy +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest # Runner must have Docker socket mounted + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "24" + cache: "npm" + - run: npm ci && npm run build + + - name: Build and run container + run: | + docker build -t garcia-inv:latest . + docker stop garcia-inv 2>/dev/null || true + docker rm garcia-inv 2>/dev/null || true + docker run -d --name garcia-inv -p 30001:80 --restart unless-stopped \ + garcia-inv:latest diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..08a8b75 --- /dev/null +++ b/dockerfile @@ -0,0 +1,17 @@ +# Stage 1: Build the React application +FROM node:24-alpine AS build +WORKDIR /app +# Copy only package files to leverage Docker layer caching +COPY package*.json ./ +RUN npm install +# Copy the rest of the source code and build +COPY . . +RUN npm run build + +# Stage 2: Serve the app with Nginx +FROM nginx:stable-alpine +# Copy built assets from the 'build' stage to Nginx's web root +# Note: Vite uses 'dist', Create React App uses 'build' +COPY --from=build /app/dist /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"]