Hosting Nodejs App using your own Docker Image in Jelastic PaaS/ Yeti Cloud

Intro Image

“ IT WORKS ON MY COMPUTER ”

Step 1: Setup a nodejs application

Step 2: Setup Dockerfile

FROM node:14 as dependencies # Use node:14 image as base and name or tag it as dependencies# Create app directory
WORKDIR /root/ROOT # Specify the folder where project lies, it will be created for you if not exists
COPY package.json ./ # Copy a package.json file to the container
RUN npm install # Install dependency from package.json
FROM node:14 as runner # Use node:14 image as base and name or tag it as runner
WORKDIR /root/ROOT # Specify the folder where project lies, it will be created for you if not exists
COPY . . # Copy all the files anf folder from project to container
COPY --from=dependencies /root/ROOT/node_modules ./node_modules # Copy node module we have installed in dependencies
ENV NODE_ENV production #SET ENV VARIABLES
ENV PORT 3000
EXPOSE 3000
# Expose port so that outside world can acces the port of container
RUN chmod +x entrypoint.sh # Make script file readable if available otherwise remove these two lines
ENTRYPOINT ["./entrypoint.sh"] # Script File if something need to be done before application starts like database migration
CMD ["npm","start"] # Start Application Command

Step 3: Build Dockerfile

docker build -t tag-name . 

Step 4: Push Docker Image

docker login # It will ask username and passworddocker push your-username/image_name

Step 5: Into Jelastic Dashboard

Create Enviroment Custom
Select Custom Container
Add Docker Image
Select Docker Image

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store