Skip to content
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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
.next
npm-debug.log
Dockerfile
docker-compose.yml
.git
.gitignore
README.md
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
NEXT_PUBLIC_MAPS_AUTOCOMPLETE_API = 'AIzaSyAxBDdnJsmCX-zQa-cO9iy-v5pn53vXEFA'
NEXT_PUBLIC_NEW_API_URL = 'https://platform.v2-dev.flexabledats.com/api/v1.0'
NEXT_PUBLIC_NFT_STORAGE_TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweGY3MTE1ZTI3NEZCQkRjNEMxMTg0NTU4M2RkNDgyZmY4Y2ZBNjg1MWYiLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTY2NDM3MDM3NTI4NCwibmFtZSI6IkZsZXhhYmxlIn0.KdNTTPilIqY9DS3KMVDqMuYUBpUsfi0fvWtztQYQwew'
NEXT_PUBLIC_AUTH = 'https://auth.staging.flexabledats.com'
NEXT_PUBLIC_NFT_STORAGE_PREFIX_URL = https://nftstorage.link/ipfs
NEXT_PUBLIC_PROJECT_ID=e5e3cd7248034842bf2c5ea640676e48

51 changes: 38 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,20 @@ jobs:

- name: NextJS Build
run: |
npm ci
if [ "$GITHUB_REF_NAME" = main ]; then echo $DEV_ENV_FILE | base64 --decode > .env; fi
if [ "$GITHUB_REF_NAME" = staging ]; then echo $STAGING_ENV_FILE | base64 --decode > .env; fi
if [ "$GITHUB_REF_NAME" = prod ]; then echo $PROD_ENV_FILE | base64 --decode > .env; fi
npm run build
npm install --legacy-peer-deps
if [ "$GITHUB_REF_NAME" = "main" ]; then
echo "$DEV_ENV_FILE" | base64 --decode > .env
elif [ "$GITHUB_REF_NAME" = "staging" ]; then
echo "$STAGING_ENV_FILE" | base64 --decode > .env
elif [ "$GITHUB_REF_NAME" = "prod" ]; then
echo "$PROD_ENV_FILE" | base64 --decode > .env
else
echo "Invalid branch: $GITHUB_REF_NAME"
exit 1
fi

echo "Environment file content:"
cat .env
env:
DEV_ENV_FILE: ${{secrets.DEV_ENV_FILE}}
STAGING_ENV_FILE: ${{secrets.STAGING_ENV_FILE}}
Expand All @@ -47,19 +56,35 @@ jobs:
.next
public
.env
retention-days: 0 # artifact retention duration, can be upto 30 days
retention-days: 1 # artifact retention duration, can be upto 30 days
ghcr-push:
name:
name: Push Image to GHCR
needs: next-build # Job depends on next-build(above) job
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout source
uses: actions/checkout@v3

- name: Download next build # Download the above uploaded artifact
uses: actions/download-artifact@v4
with:
name: build
fetch-depth: 0

- name: Setup environment file based on branch
run: |
echo "Branch detected: $GITHUB_REF_NAME"
if [ "$GITHUB_REF_NAME" = "main" ]; then
echo "$DEV_ENV_FILE" | base64 -d > .env
elif [ "$GITHUB_REF_NAME" = "staging" ]; then
echo "$STAGING_ENV_FILE" | base64 -d > .env
elif [ "$GITHUB_REF_NAME" = "prod" ]; then
echo "$PROD_ENV_FILE" | base64 -d > .env
fi
echo "Generated .env file:"
cat .env
env:
DEV_ENV_FILE: ${{ secrets.DEV_ENV_FILE }}
STAGING_ENV_FILE: ${{ secrets.STAGING_ENV_FILE }}
PROD_ENV_FILE: ${{ secrets.PROD_ENV_FILE }}


- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand Down Expand Up @@ -128,4 +153,4 @@ jobs:
sudo podman pull ghcr.io/weareflexable/portal:prod
sudo podman stop portal
sudo podman rm portal
sudo podman run --name="portal" -p 9083:3000 -d ghcr.io/weareflexable/portal:prod
sudo podman run --name="portal" -p 9083:3000 -d ghcr.io/weareflexable/portal:prod
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
73 changes: 34 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
# Install dependencies only when needed
FROM node:18-alpine 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
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# --- Step 1: Build Stage ---
FROM node:16-bullseye AS builder

# If using npm with a `package-lock.json` comment out above and use below instead
# COPY package.json package-lock.json ./
# RUN npm ci
# Install system dependencies for native modules
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
build-essential

# Rebuild the source code only when needed
FROM node:16-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules


# Copy package files first for better caching
COPY package*.json ./

# Force install legacy peer deps (important for AntD 5 + Chakra + Next.js)
RUN npm config set legacy-peer-deps true
RUN npm ci


# After npm install
RUN npm install && npm run postinstall
# Copy rest of the application code
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1
# Before build
COPY .env .env
# Ensure TypeScript builds correctly
RUN npm run build

RUN yarn build
# --- Step 2: Production Runner Stage ---
FROM node:18-alpine AS runner

# If using npm comment out above and use below instead
# RUN npm run build

# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Only copy what’s needed to run

# You only need to copy next.config.js if you are NOT using the default configuration
# COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/next.config.js ./next.config.js

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs
ENV NODE_ENV=production

EXPOSE 3000

ENV PORT 3000

CMD ["node", "server.js"]
# Use node instead of npm (better control)
CMD ["node", "node_modules/next/dist/bin/next", "start"]
Loading