diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..8141944 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 77f3f6a..0000000 --- a/Dockerfile +++ /dev/null @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 2c1f3ee..0000000 --- a/docker-compose.yml +++ /dev/null @@ -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 diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 0000000..8dd11ff --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,13 @@ +module.exports = { + apps: [ + { + name: "portal-dias-rota", + script: ".next/standalone/server.js", + args: "start", + env: { + NODE_ENV: "production", + PORT: 3003 + } + } + ] +}; \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs index 5c21671..448e1ad 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,5 +1,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'standalone', // <--- ADICIONE ISSO + // Next 16+: use `serverExternalPackages` instead of experimental.serverComponentsExternalPackages serverExternalPackages: ['oracledb'], @@ -16,4 +18,4 @@ const nextConfig = { }, }; -export default nextConfig; +export default nextConfig; \ No newline at end of file