feat: Add Gitea CI/CD and PM2 deployment for Next.js standalone output, removing Docker files.
Deploy Next.js Local / build-and-deploy (push) Waiting to run Details

This commit is contained in:
JuruSysadmin 2026-01-07 14:55:42 -03:00
parent 303dd1390f
commit 84319d4037
5 changed files with 39 additions and 88 deletions

View File

@ -0,0 +1,23 @@
name: Deploy Next.js Local
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Instalar Dependências
run: npm install
- name: Build do Next.js
run: npm run build
- name: Deploy com PM2
run: |
pm2 restart portal-dias-rota || pm2 start ecosystem.config.js
pm2 save

View File

@ -1,56 +0,0 @@
FROM node:20-alpine AS builder
WORKDIR /app
RUN apk add --no-cache libaio libnsl libc6-compat curl unzip
RUN mkdir -p /opt/oracle && \
cd /opt/oracle && \
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/2340000/instantclient-basiclite-linux.x64-23.4.0.24.05.zip && \
unzip instantclient-basiclite.zip && \
rm -f instantclient-basiclite.zip && \
cd instantclient_23_4 && \
rm -f *jdbc* *occi* *mysql* *jar uidrvci genezi adrci && \
echo /opt/oracle/instantclient_23_4 > /etc/ld.so.conf.d/oracle-instantclient.conf && \
ldconfig
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient_23_4:$LD_LIBRARY_PATH
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine AS runner
WORKDIR /app
RUN apk add --no-cache libaio libnsl libc6-compat
COPY --from=builder /opt/oracle/instantclient_23_4 /opt/oracle/instantclient_23_4
RUN echo /opt/oracle/instantclient_23_4 > /etc/ld.so.conf.d/oracle-instantclient.conf && \
ldconfig
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient_23_4:$LD_LIBRARY_PATH
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
RUN chown -R nextjs:nodejs /app
USER nextjs
EXPOSE 3003
ENV NODE_ENV=production
ENV PORT=3003
CMD ["node", "server.js"]

View File

@ -1,31 +0,0 @@
version: '3.8'
services:
portal-dias-rota:
image: ${REGISTRY_URL}/portal-dias-rota:latest
container_name: portal-dias-rota
restart: unless-stopped
ports:
- "3003:3003"
environment:
- NODE_ENV=production
- ORACLE_USER=${ORACLE_USER}
- ORACLE_PASSWORD=${ORACLE_PASSWORD}
- ORACLE_CONNECTION_STRING=${ORACLE_CONNECTION_STRING}
- ORACLE_POOL_MIN=${ORACLE_POOL_MIN:-1}
- ORACLE_POOL_MAX=${ORACLE_POOL_MAX:-30}
- ORACLE_POOL_INCREMENT=${ORACLE_POOL_INCREMENT:-1}
- ORACLE_QUEUE_TIMEOUT=${ORACLE_QUEUE_TIMEOUT:-60000}
- ORACLE_INACTIVITY_TIMEOUT=${ORACLE_INACTIVITY_TIMEOUT:-20000}
networks:
- portal-network
healthcheck:
test: [ "CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3003" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
portal-network:
driver: bridge

13
ecosystem.config.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
apps: [
{
name: "portal-dias-rota",
script: ".next/standalone/server.js",
args: "start",
env: {
NODE_ENV: "production",
PORT: 3003
}
}
]
};

View File

@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
output: 'standalone', // <--- ADICIONE ISSO
// Next 16+: use `serverExternalPackages` instead of experimental.serverComponentsExternalPackages // Next 16+: use `serverExternalPackages` instead of experimental.serverComponentsExternalPackages
serverExternalPackages: ['oracledb'], serverExternalPackages: ['oracledb'],