feat: setup standalone build and docker deployment
This commit is contained in:
@@ -40,3 +40,21 @@ jobs:
|
|||||||
next.config.*
|
next.config.*
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
.npmrc
|
.npmrc
|
||||||
|
public
|
||||||
|
Dockerfile
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build-and-test
|
||||||
|
runs-on: CDCD
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: next-build
|
||||||
|
|
||||||
|
- name: Deploy to Docker
|
||||||
|
run: |
|
||||||
|
docker build -t nextjs-app .
|
||||||
|
docker stop nextjs-app || true
|
||||||
|
docker rm nextjs-app || true
|
||||||
|
docker run -d -p 3492:3000 --restart unless-stopped --name nextjs-app nextjs-app
|
||||||
|
|||||||
22
Dockerfile
Normal file
22
Dockerfile
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
FROM node:22-alpine AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV production
|
||||||
|
|
||||||
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
|
# Copy standalone output
|
||||||
|
# We assume the context contains the .next folder and public folder from the artifacts
|
||||||
|
COPY --chown=nextjs:nodejs .next/standalone ./
|
||||||
|
COPY --chown=nextjs:nodejs .next/static ./.next/static
|
||||||
|
COPY --chown=nextjs:nodejs public ./public
|
||||||
|
|
||||||
|
USER nextjs
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
ENV PORT 3000
|
||||||
|
ENV HOSTNAME "0.0.0.0"
|
||||||
|
|
||||||
|
CMD ["node", "server.js"]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
/* config options here */
|
output: "standalone",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user