Skip to content

Commit

Permalink
refactor Dockerfile for gateway frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennievon committed Oct 16, 2024
1 parent 0dc8452 commit b429c61
Showing 1 changed file with 23 additions and 34 deletions.
57 changes: 23 additions & 34 deletions tools/walletextension/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,39 @@
# Node.js LTS version
# Use an official Node.js LTS version as a base image
FROM node:18-buster AS base

# Install pnpm
RUN npm install -g pnpm

# build-time arguments
ARG NEXT_PUBLIC_NETWORK_NAME
ARG NEXT_PUBLIC_TENSCAN_URL
ARG NEXT_PUBLIC_GATEWAY_URL
ARG NEXT_PUBLIC_API_HOST_ENVIRONMENT

# environment variabless
ENV NEXT_PUBLIC_NETWORK_NAME=$NEXT_PUBLIC_NETWORK_NAME
ENV NEXT_PUBLIC_TENSCAN_URL=$NEXT_PUBLIC_TENSCAN_URL
ENV NEXT_PUBLIC_GATEWAY_URL=$NEXT_PUBLIC_GATEWAY_URL
ENV NEXT_PUBLIC_API_HOST_ENVIRONMENT=$NEXT_PUBLIC_API_HOST_ENVIRONMENT

# Set the working directory
WORKDIR /usr/src/app
WORKDIR /home/obscuro/go-obscuro/

# copy app source
COPY tools/walletextension/frontend/ .
# Copy the entire project
COPY . .

# Install dependencies
# Install dependencies for the entire project
RUN pnpm install

# Build the Next.js app
RUN pnpm run build
# Set the working directory for the frontend
WORKDIR /home/obscuro/go-obscuro/tools/walletextension/frontend

# using a lighter image for the final build
FROM node:18-buster AS runner
# Install dependencies specific to the frontend
RUN pnpm install --filter ./tools/walletextension/frontend...

# working directory
WORKDIR /usr/src/app
# Build the Next.js app (if needed)
# RUN pnpm run build

# Copy the necessary files from the base image
COPY --from=base /usr/src/app/.next ./.next
COPY --from=base /usr/src/app/public ./public
COPY --from=base /usr/src/app/package*.json ./

# Install only production dependencies
RUN pnpm install --production
# Set environment variables
ARG NEXT_PUBLIC_NETWORK_NAME
ARG NEXT_PUBLIC_TENSCAN_URL
ARG NEXT_PUBLIC_GATEWAY_URL
ARG NEXT_PUBLIC_API_HOST_ENVIRONMENT
ENV NEXT_PUBLIC_NETWORK_NAME=$NEXT_PUBLIC_NETWORK_NAME
ENV NEXT_PUBLIC_TENSCAN_URL=$NEXT_PUBLIC_TENSCAN_URL
ENV NEXT_PUBLIC_GATEWAY_URL=$NEXT_PUBLIC_GATEWAY_URL
ENV NEXT_PUBLIC_API_HOST_ENVIRONMENT=${NEXT_PUBLIC_API_HOST_ENVIRONMENT}

# Set environment variable and expose port
ENV PORT=80
# Expose the port
EXPOSE 80

# start the app
CMD ["pnpm", "start"]
# Start the application
CMD ["pnpm", "run", "start"]

0 comments on commit b429c61

Please sign in to comment.