Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #7

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.git
node_modules
docker-compose.yml
Dockerfile
.prettierrc
.prettierignore
.gitignore
.eslintrc.js
README.md
.husky
.github
.next
!.next/static
!.next/standalone
26 changes: 26 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CD

on:
workflow_run:
workflows: ["CI"]
branches: ["main"]
types:
- completed

jobs:
deploy:
name: deploy
runs-on: self-hosted
if: ${{
github.event.workflow_run.conclusion == 'success'
&& github.event.workflow_run.event == 'push'
}}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Deploy docker-compose stack
run: docker compose up -d --build --force-recreate

- name: Prune Docker system
run: docker system prune -af
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches:
- main
- develop
pull_request:
branches:
- develop

jobs:
lint-and-build:
name: lint-and-build
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js Environment
uses: actions/setup-node@v4
with:
node-version: 20

- name: Setup pnpm
uses: pnpm/action-setup@v4.0.0
with:
version: 9

- name: Install Dependencies
run: pnpm install --no-frozen-lockfile

- name: Run linting
run: pnpm lint-staged --allow-empty

- name: Build application
run: pnpm run build
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM node:20-alpine As base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

RUN corepack enable

WORKDIR /usr/app

FROM base As deps

COPY package.json pnpm-lock.yaml ./

RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store pnpm install --frozen-lockfile

FROM base As builder

COPY --from=deps --chown=nextjs:nodejs /usr/app/node_modules ./node_modules
COPY . .

RUN pnpm run build

FROM node:20-alpine As runner

WORKDIR /usr/app

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
RUN mkdir .next
RUN chown nextjs:nodejs .next

USER nextjs

COPY --chown=nextjs:nodejs --from=builder /usr/app/node_modules ./node_modules
COPY --chown=nextjs:nodejs --from=builder /usr/app/.next/standalone ./
COPY --chown=nextjs:nodejs --from=builder /usr/app/.next/static ./.next/static

EXPOSE 3000

CMD [ "node", "server.js" ]
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
reg_helper:
container_name: reg_helper
build:
context: .
dockerfile: Dockerfile
restart: always
ports:
- 3000:3000
4 changes: 3 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
output: 'standalone'
};

export default nextConfig;