Add Docker build and Gitea Actions CI/CD pipeline
Some checks failed
Build and deploy action / deploy (push) Failing after 16s

Standalone Next.js output, production Dockerfile, and a workflow
that builds+deploys to garage on push.
This commit is contained in:
Linas Puplauskas 2026-08-24 19:47:22 +03:00
parent 49f57045e2
commit a61a580302
4 changed files with 67 additions and 1 deletions

6
.dockerignore Normal file
View File

@ -0,0 +1,6 @@
node_modules
.next
.git
.idea
*.tsbuildinfo
README.md

View File

@ -0,0 +1,37 @@
name: Build and deploy action
run-name: build and deploy
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Package source
run: tar czf frontend.tar.gz --exclude=.git --exclude=node_modules --exclude=.next .
- name: Upload source to garage
uses: appleboy/scp-action@v1
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
port: 22
source: "frontend.tar.gz"
target: "/tmp/"
- name: Build image and restart
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
port: 22
script: |
rm -rf /opt/docker/ente_nazionale_frontend/*
tar xzf /tmp/frontend.tar.gz -C /opt/docker/ente_nazionale_frontend
rm /tmp/frontend.tar.gz
docker build --build-arg NEXT_PUBLIC_API_URL=https://encap-be.kkava.lt/api -t ente-nazionale-frontend:1 /opt/docker/ente_nazionale_frontend
cd /opt/docker && docker compose up -d --force-recreate ente-nazionale-frontend

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM node:22-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
ARG NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
RUN npm run build
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]

View File

@ -1,7 +1,7 @@
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
output: "standalone",
};
export default nextConfig;