-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from reedu-reengineering-education/feat/add-gi…
…t-actions Feat/add git actions
- Loading branch information
Showing
9 changed files
with
189 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#---------------> Ignore directories | ||
node_modules | ||
.next | ||
out | ||
build | ||
|
||
#---------------> Ignore environment files | ||
.env* | ||
!.env.example | ||
|
||
#---------------> Local development | ||
*.log | ||
*.cache | ||
.npm | ||
.nuxt | ||
|
||
#---------------> System files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
#---------------> Version control | ||
.git | ||
.gitignore | ||
|
||
#---------------> Dependency directories | ||
bower_components | ||
.jest | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Build and publish to Github Container Registry | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
tags: [ 'v*.*.*' ] | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-images: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
flavor: | | ||
latest=auto | ||
prefix= | ||
suffix= | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Purge Pull Request Image | ||
|
||
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#registry_package | ||
# Purge Pull Request Image | ||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
purge_pr_image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Purge Pull Request Image | ||
uses: vlaurin/[email protected] | ||
with: | ||
token: ${{ secrets.GHCR_TOKEN}} | ||
organization: ${{ github.repository_owner}} | ||
container: ${{ github.event.repository.name }} | ||
prune-tags-regexes: pr-${{github.event.pull_request.number}}$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Purge untagged images | ||
|
||
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#registry_package | ||
# Run cleanup job if a new package was published or updated | ||
on: | ||
registry_package: | ||
|
||
jobs: | ||
purge_untagged_images: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: clean packages | ||
uses: vlaurin/[email protected] | ||
with: | ||
token: ${{ secrets.GHCR_TOKEN}} | ||
organization: ${{ github.repository_owner}} | ||
container: ${{ github.event.repository.name }} | ||
prune-untagged: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#-----------------------------> Base Image | ||
FROM node:18-alpine AS base | ||
|
||
# ---------------------------> Dependency Installation | ||
FROM base AS deps | ||
|
||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.json* ./ | ||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
#-------------------------> Next.JS Build | ||
FROM base as builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
RUN npx prisma generate | ||
|
||
RUN yarn build | ||
|
||
#-------------------------> Start Next.JS Server | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
|
||
RUN addgroup --system --gid 1001 nextjs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
USER nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
COPY --from=builder /app/.next/standalone ./ | ||
COPY --from=builder /app/.next/static ./.next/static | ||
|
||
EXPOSE 1000 | ||
|
||
ENV PORT 3000 | ||
ENV HOSTNAME localhost | ||
|
||
CMD [ "node", "server.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
const nextConfig = {output: "standalone"} | ||
|
||
module.exports = nextConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.