R
Railway2y ago
ErikT

Having issue deploying for the first time with Dockerfile

Hey! I just deployed my application successfully and the instance logs say it is running on port 8000 (which I get locally too so it is working as expected). But when I go to the domain I setup -- https://api.wriggly.io/ -- I get the following message "Application error: a client-side exception has occurred (see the browser console for more information)." This is my deploymentID 456ea53 Additionally, is this potentially an issue with my Dockerfile? I know when I run the dockerfile locally I run docker run -p 8000:8000 {containername} to map it to the external port 8000. does that matter?
18 Replies
Percy
Percy2y ago
Project ID: cccc72dc-c205-4c79-80cb-eb2f054ee9d1
Percy
Percy2y ago
ErikT
ErikTOP2y ago
Project ID: cccc72dc-c205-4c79-80cb-eb2f054ee9d1
Brody
Brody2y ago
you want your app to listen on $PORT not 8000
ErikT
ErikTOP2y ago
oh got it do I configure this in environment variables? also since my dockerfile sets it up to run on port 8000 will I need to update my dockerfile to read this var ?
Brody
Brody2y ago
send the dockerfile?
ErikT
ErikTOP2y ago
one sec
FROM node:14.17.0-alpine
# FROM node:15 went from 1.2 gb to 350mb with alpine

# Create app directory
WORKDIR .

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

EXPOSE 8000
CMD [ "node", "app.js" ]
FROM node:14.17.0-alpine
# FROM node:15 went from 1.2 gb to 350mb with alpine

# Create app directory
WORKDIR .

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

EXPOSE 8000
CMD [ "node", "app.js" ]
Brody
Brody2y ago
thats broken
ErikT
ErikTOP2y ago
logs look good though
Brody
Brody2y ago
i know
ErikT
ErikTOP2y ago
oh got it -- what looks wrong ?
Brody
Brody2y ago
few things you are using the root as the workdir you want WORKDIR /app remove the EXPOSE and in app.js have it listen on process.env.PORT || 8000
ErikT
ErikTOP2y ago
ok trying to deploy this thank you Cool my new std out is
NODE_ENV: production
listen port 7431
NODE_ENV: production
listen port 7431
Brody
Brody2y ago
looks good
ErikT
ErikTOP2y ago
wow this is working thanks so much for all the help here!!! 🙌
Brody
Brody2y ago
you've changed the workdir right?
ErikT
ErikTOP2y ago
uhhh this is the new docker file I need to make some requests against the service to ensure it works but it looks correct
FROM node:14.17.0-alpine
# FROM node:15 went from 1.2 gb to 350mb with alpine

# Create app directory
WORKDIR /app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

CMD [ "node", "app.js" ]
FROM node:14.17.0-alpine
# FROM node:15 went from 1.2 gb to 350mb with alpine

# Create app directory
WORKDIR /app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

CMD [ "node", "app.js" ]
Brody
Brody2y ago
looks good enough to me
Want results from more Discord servers?
Add your server