-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor Dockerfile for gateway frontend
- Loading branch information
Showing
1 changed file
with
23 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |