Skip to content

Commit

Permalink
feat: docker deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtiti committed Sep 2, 2024
1 parent 2d61ae7 commit de0a52a
Show file tree
Hide file tree
Showing 5 changed files with 8,885 additions and 6,956 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ignore all .env files in any directory or subdirectory
**/.env

# Ignore node_modules and dist directories in any directory or subdirectory
**/node_modules
**/dist

**/.git
**/*.md
**/cypress
**/.github
.next
!.next/static
!.next/standalone
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Use an official Node.js image as a parent image
FROM node:20 AS build
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# # Install pnpm globally
# RUN npm install -g pnpm


# Set the working directory in the container
WORKDIR /app

# Copy pnpm-lock.yaml and package.json files
COPY package.json pnpm-lock.yaml ./

# Install dependencies using pnpm
RUN CI=1 pnpm install --frozen-lockfile

# Copy the rest of the application code
COPY . .

# Build the application
RUN pnpm build

# Use a lighter Node.js image for the final stage
FROM node:20-slim AS ui
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV NODE_ENV=production
RUN corepack enable

# Set the working directory in the container
WORKDIR /app

# Copy only necessary files from the build stage
COPY --from=build /app/package.json /app/pnpm-lock.yaml ./
COPY --from=build /app/public ./public
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static


# # Install only production dependencies with pnpm
# RUN CI=1 pnpm install --no-frozen-lockfile

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

# Specify the command to run the application
CMD ["node", "server.js"]
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const nextConfig = {
locales: ['en', 'es'],
defaultLocale: 'en',
},
output: 'standalone',
};

export default nextConfig;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"prettier:fix": "pnpm run prettier -- --write",
"format": "pnpm run prettier:fix && yarn run lint:fix",
"format:check": "pnpm run prettier && yarn run lint",
"prepare": "husky install && wonderland-crypto-husky-checks install",
"prepare": "husky install && (is-ci || wonderland-crypto-husky-checks install)",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"test:e2e": "pnpm cypress run",
Expand All @@ -41,6 +41,7 @@
"@rainbow-me/rainbowkit": "2.1.4",
"@tanstack/react-query": "5.28.0",
"i18next": "23.7.6",
"is-ci": "3.0.1",
"next": "14.2.5",
"next-i18next": "15.2.0",
"react": "18.2.0",
Expand Down
Loading

0 comments on commit de0a52a

Please sign in to comment.