Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup: add docker file #930

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

setup: add docker file #930

wants to merge 3 commits into from

Conversation

satyam73
Copy link
Member

@satyam73 satyam73 commented Sep 4, 2024

Date: to be filled

Developer Name: Satyam Bajpai


Issue Ticket Number:-

Description:

Add description of the PR here

Is Under Feature Flag

  • Yes
  • No

Database changes

  • Yes
  • No

Breaking changes (If your feature is breaking/missing something please mention pending tickets)

  • Yes
  • No

Is Development Tested?

  • Yes
  • No

Tested in staging?

  • Yes
  • No

Add relevant Screenshot below ( e.g test coverage etc. )

Copy link

cloudflare-workers-and-pages bot commented Sep 4, 2024

Deploying www-rds with  Cloudflare Pages  Cloudflare Pages

Latest commit: 43a5ed7
Status: ✅  Deploy successful!
Preview URL: https://1cea5511.www-rds.pages.dev
Branch Preview URL: https://setup-dockerize-app.www-rds.pages.dev

View logs

@satyam73 satyam73 self-assigned this Sep 6, 2024
@satyam73 satyam73 marked this pull request as draft September 6, 2024 20:30
@satyam73
Copy link
Member Author

satyam73 commented Sep 6, 2024

Currently the app is not running in docker container(in terminal I am getting correct output) and when I am running normally(means without docker) it is working fine and I can see the app running on the respective port.

For docker

  • Checkout to this branch
  • Run docker build . command inside website-www directory. Wait till docker image is creating.
  • After it gets created run docker images to see the image, copy the id of latest image(which got build just now)
  • Run the image with command docker run <IMAGE_ID>
  • Check that it will spin up the fastboot workers and app will be served in port 5000(When going to http://localhost:5000 I am not seeing running app that's the actual issue whereas when I am running without docker as steps mentioned below I am able to see the app running on http://localhost:5000)

For without docker

  • Checkout to this branch
  • Make sure you have done yarn install
  • Run yarn build to build the app
  • After build succeeds run node fastboot-server.js
  • Check that it will spin up the fastboot workers and app will be served in port 5000

Update

The above issue is resolved more context below

So the issue was I was using the command docker run <IMAGE_ID>

So it was correctly not mapping the port of my machine and the docker machine

By using the command docker run -p <host_port>:<container_port> <image_name> it started to map the container port my host port and everything worked fine, I can see my app running in the browser.

Updated steps to run docker

  • Run docker build . to build image.
  • After image gets created run docker images to see the images, copy the id of latest image(which got build just now)
  • Run the image with command docker run -p 5000:5000 <IMAGE_ID>
  • Go to http://localhost:5000/ and we will see our app running.

Comment on lines 17 to 20
// API_BACKEND: `${SCHEME}api.${DOMAIN}`,hostWhitelist

API_BACKEND: `http://localhost:3000`,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed?

Copy link
Member Author

@satyam73 satyam73 Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes was testing, forgot to remove, thanks for pointing it out.
Update it now

Comment on lines 1 to 4
// import FastBootAppServer from 'fastboot-app-server';

// eslint-disable-next-line no-undef
const FastBootAppServer = require('fastboot-app-server');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not using commonjs? and using require?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was facing error in other files while I was using es6 code, so that's why instead of changing them I changed this one only

Dockerfile Outdated
@@ -0,0 +1,27 @@
# Utilize the Node.js 14 official image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why node 14?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outdated comment, have updated

@@ -0,0 +1,27 @@
# Utilize the Node.js 14 official image
FROM node:18-alpine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the current latest version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current version in v20.17.0 using this one because in our volta package 18 version is pinned

Dockerfile Outdated
Comment on lines 4 to 27
USER root

# Set the working directory inside the container
WORKDIR /app

# Copy the package.json and package-lock.json (if available)
# COPY package*.json ./

# Install the dependencies


# Copy the rest of the application code
COPY . .

RUN yarn install --frozen-lockfile

# Build the Fastboot app
RUN yarn build

# Expose the port the Fastboot app runs on
EXPOSE 5000

# Define the command to run your Fastboot app
CMD ["node", "fastboot-server"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the app know in which env to run

Copy link
Member Author

@satyam73 satyam73 Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this we can have a two docker file one for production and one for staging with two different build commands

@satyam73 satyam73 marked this pull request as ready for review September 15, 2024 12:16
@satyam73 satyam73 changed the title draft: write initial docker file setup: add docker file Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants