diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3948b69 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +.next +.git +.idea +*.tsbuildinfo +README.md diff --git a/.gitea/workflows/buildAndDeploy.yaml b/.gitea/workflows/buildAndDeploy.yaml new file mode 100644 index 0000000..31a422b --- /dev/null +++ b/.gitea/workflows/buildAndDeploy.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..65c2780 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/next.config.ts b/next.config.ts index e9ffa30..68a6c64 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,7 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { - /* config options here */ + output: "standalone", }; export default nextConfig;