Created
October 21, 2023 10:00
-
-
Save piyushgarg-dev/ea8c5aa52de0496753b88cd938abd728 to your computer and use it in GitHub Desktop.
Docker In One Shot
This file contains hidden or 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
version: "3.8" | |
services: | |
postgres: | |
image: postgres # hub.docker.com | |
ports: | |
- "5432:5432" | |
environment: | |
POSTGRES_USER: postgres | |
POSTGRES_DB: review | |
POSTGRES_PASSWORD: password | |
redis: | |
image: redis | |
ports: | |
- "6379:6379" |
This file contains hidden or 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
FROM ubuntu | |
RUN apt-get update | |
RUN apt-get install -y curl | |
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - | |
RUN apt-get upgrade -y | |
RUN apt-get install -y nodejs | |
COPY package.json package.json | |
COPY package-lock.json package-lock.json | |
COPY main.js main.js | |
RUN npm install | |
ENTRYPOINT [ "node", "main.js" ] |
This worked for me:
FROM ubuntu:latest
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs
RUN node -v
RUN npm -v
COPY package.json package-lock.json ./
RUN npm install
COPY index.js .
EXPOSE 3000
CMD ["node", "index.js"]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this one for maximum efficient output with no error:
1-----------------------------------------------------------------------------
FROM ubuntu
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get upgrade -y
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs
COPY package.json package.json
COPY package-lock.json package-lock.json
COPY index.js index.js
RUN npm install
ENTRYPOINT [ "node","index.js" ]
2--------------------------------------------------
FROM node
COPY package.json package.json
COPY package-lock.json package-lock.json
COPY index.js index.js
RUN npm install
ENTRYPOINT [ "node","index.js" ]