Skip to content

Commit

Permalink
fixing docker build in dockerfile yarn install issue
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterNashaat committed May 22, 2024
1 parent e0560d1 commit bfce821
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
FROM ubuntu:latest as builder
RUN apt-get update

# Is optional, but if you are not going to use this then you will need to install
# 'gnupg' for nodesource so it can setup node install
RUN apt-get install -y build-essential python-is-python3 make gcc g++

RUN apt-get -y install curl

# The next 2 steps will install node
#RUN curl -sL https://deb.nodesource.com/setup_15.x | bash -

RUN curl -LO https://nodejs.org/dist/v18.0.0/node-v18.0.0-linux-x64.tar.xz sudo tar -xvf node-v18.0.0-linux-x64.tar.xz sudo cp -r node-v18.0.0-linux-x64/{bin,include,lib,share} /usr/ node --version => v18.0.0

# The next 3 steps are for installing yarn
RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -


RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list

RUN apt-get update && apt-get install yarn -y

FROM python:2.7 as builder

# Update and install dependencies
RUN apt-get update && \
apt-get install -y build-essential make gcc g++ curl gnupg

# Install Node.js
RUN curl -LO https://nodejs.org/dist/v18.0.0/node-v18.0.0-linux-x64.tar.xz && \
tar -xvf node-v18.0.0-linux-x64.tar.xz && \
cp -r node-v18.0.0-linux-x64/bin/* /usr/bin/ && \
cp -r node-v18.0.0-linux-x64/include/* /usr/include/ && \
cp -r node-v18.0.0-linux-x64/lib/* /usr/lib/ && \
cp -r node-v18.0.0-linux-x64/share/* /usr/share/ && \
node --version

# Install Yarn
RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y yarn

WORKDIR /app

# Show Node.js version
RUN node --version

COPY package.json package.json
COPY yarn.lock yarn.lock

# Copy and install dependencies
COPY package.json yarn.lock ./
RUN yarn install

# Copy the rest of the application code
COPY . .

# Build the application
RUN yarn build

# Use Nginx as the server
FROM nginx:alpine as server
COPY --from=builder /app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]

0 comments on commit bfce821

Please sign in to comment.