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

feat(ci): Update Github Actions for Docker Build+Publish #1919

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.unit.ts
58 changes: 58 additions & 0 deletions .github/workflows/release-apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release Apps

on:
release:
types: [published]
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
if: github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Set up QEMU
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0

- name: Login to GitHub Container Registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/birthdayresearch/defiscan
tags: |
type=ref,event=tag,priority=400
type=sha,suffix=-{{date 'x'}},priority=300
type=sha,format=long,priority=200
type=ref,event=branch,priority=100

- name: Build & Publish
uses: docker/build-push-action@v4
with:
context: .
platforms: |
linux/amd64
linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
31 changes: 23 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
FROM node:18-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat

# Set the working directory inside the container
WORKDIR /app

# Copy the package files to the working directory
COPY package.json pnpm-lock.yaml /app/

# Install PNPM globally
RUN npm install -g pnpm

# Install project dependencies using PNPM
RUN pnpm install --ignore-scripts puppeteer
# To check why lossless-json is not installed by jellyfishsdk
RUN pnpm install [email protected]
RUN yarn global add pnpm && pnpm i --ignore-scripts

# Copy the rest of the application code
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Build the Next.js application
RUN pnpm run build
RUN yarn global add pnpm && pnpm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production

# Copy build files
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

# Expose the port on which the application will run
EXPOSE 3000
ENV PORT 3000

# Start the Next.js application
CMD ["pnpm", "start"]
CMD ["node", "server.js"]
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ module.exports = {
},
];
},
output: "standalone",
};
21 changes: 20 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
},
"dependencies": {
"@babel/types": "^7.23.5",
"@defichain/jellyfish-address": "^4.0.1",
"@defichain/jellyfish-api-core": "^4.0.1",
"@defichain/jellyfish-network": "^4.0.1",
"@defichain/jellyfish-transaction": "^4.0.1",
"@defichain/playground-api-client": "^4.0.1",
"@defichain/whale-api-client": "^4.0.1",
"@floating-ui/react-dom": "^1.3.0",
"@headlessui/react": "^1.7.17",
"@prismicio/client": "^7.2.0",
Expand All @@ -35,13 +41,22 @@
"install": "^0.13.0",
"jest": "^29.7.0",
"lodash": "^4.17.21",
"lossless-json": "1.0.5",
"next": "^14.0.3",
"next-sitemap": "^4.2.3",
"nextjs-progressbar": "^0.0.16",
"puppeteer": "^21.5.2",
"qrcode.react": "^3.1.0",
"randomcolor": "^0.6.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.12.0",
"react-number-format": "^5.3.1",
"react-redux": "^8.1.2",
"react-schemaorg": "^2.0.0",
"recharts": "^2.10.2",
"schema-dts": "^1.1.2",
"sharp": "^0.33.0",
"smart-buffer": "^4.2.0"
},
"devDependencies": {
Expand All @@ -50,6 +65,7 @@
"@netlify/plugin-nextjs": "^4.41.1",
"@stickyjs/jest": "^1.3.4",
"@testing-library/cypress": "^9.0.0",
"@types/jest": "^29.5.11",
"@types/lodash": "^4.14.202",
"@types/node": "^18.16.18",
"@waveshq/standard-web-linter": "^1.9.3",
Expand All @@ -65,5 +81,8 @@
"node": ">=18.0.0",
"pnpm": ">=8.11.0"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"eslintIgnore": [
"*.unit.ts"
]
}
Loading