manifestinteractive / teleprompter

Browser-based TelePrompter with Remote Control
https://promptr.tv
Other
316 stars 113 forks source link

Docker File #35

Closed mmBesar closed 1 year ago

mmBesar commented 2 years ago

Amazing Application, thanks!

I do not code, but I need to self-host my services and applications, due to poor internet service! But I failed to build a docker image for it! Please Guide me! What am I doing wrong here!

Regards

Here is my docker file:

FROM node:12.22.6-alpine

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
RUN apk add --update git
RUN git clone https://github.com/manifestinteractive/teleprompter.git /usr/src/app
RUN apk del git

# 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 . .

ENV PORT=8080
ENV PORT=3000

EXPOSE 8080
EXPOSE 3000
CMD [ "npm", "start" ]
mcoms commented 2 years ago

I've just tried to do this too — what's wrong is npm start immediately demonises into the background (due to the use of forever, see package.json), causing the container to exit immediately. The fix is to change your CMD to be CMD ["npm", "run", "server"], which blocks.

You'll actually need to run two containers, one for the client and one for the remote ("server"). I would suggest removing CMD altogether and instead using ENTRYPOINT:

# Dockerfile
FROM node
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN npm install
EXPOSE 3000
EXPOSE 8080
ENTRYPOINT ["npm", "run"]
CMD ["server"]
# docker-compose.yml
services:
  server:
    build: .
    command: server
    ports:
      - '3000:3000'
  client:
    build: .
    command: client
    ports:
      - '8080:8080'
docker compose up

The DEVELOPERS.md file mentions the correct way to deploy this project is behind a reverse proxy like nginx, but the docker/compose files above were good enough for me to get running in development mode, quite enough to have the project running across a local network.

manifestinteractive commented 2 years ago

Seems like you've actually got a fix in place. If you wouldn't mind submitting that as a PR, I'd happily merge your changes :)

mmBesar commented 2 years ago

That is why open source is great.
I'll try it as soon as I can and report back.
@mcoms @manifestinteractive Thank you.