diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2628355 --- /dev/null +++ b/.dockerignore @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fb70be3 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/README.md b/README.md index 7af5105..39612e2 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,34 @@ Vercel will automatically deploy your project and provide a live URL. - **[Vercel CLI Documentation](https://vercel.com/docs/cli)**: Find comprehensive information on using the Vercel CLI. - **[Vercel Documentation](https://vercel.com/docs)**: Access general Vercel documentation and guides. +## 🐳 Docker deployment + +## Prerequisites + +- **Docker**: Ensure that Docker is installed. + +## Deployment Steps + +1. **Build the Docker Image** + + From your project directory, build the Docker image by running the following command: + + ```bash + docker build -t . + ``` + +2. **Run the Docker Container** + + After the image is built, run the Docker container with the environment variables. + + ```bash + docker run -p 5173:5173 --env-file .env + ``` + +3. **Access your app:** + + http://localhost:5173 + ## Development ### 💻 Conventional Commits diff --git a/next.config.mjs b/next.config.mjs index 404aa72..430c845 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -5,6 +5,7 @@ const nextConfig = { locales: ['en', 'es'], defaultLocale: 'en', }, + output: 'standalone', }; export default nextConfig; diff --git a/package.json b/package.json index a2ecdbd..5e70ddf 100644 --- a/package.json +++ b/package.json @@ -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", @@ -42,6 +42,7 @@ "@tanstack/react-query": "5.28.0", "cypress": "13.14.1", "i18next": "23.7.6", + "is-ci": "3.0.1", "next": "14.2.5", "next-i18next": "15.2.0", "react": "18.2.0", @@ -64,6 +65,7 @@ "@types/react-dom": "18.2.7", "@typescript-eslint/eslint-plugin": "6.0.0", "@typescript-eslint/parser": "6.0.0", + "cypress": "13.14.1", "eslint": "8.45.0", "eslint-config-prettier": "9.0.0", "eslint-plugin-import": "2.28.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5314bb8..14fbd57 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: i18next: specifier: 23.7.6 version: 23.7.6 + is-ci: + specifier: 3.0.1 + version: 3.0.1 next: specifier: 14.2.5 version: 14.2.5(@babel/core@7.24.1)(babel-plugin-macros@3.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)