From d49112f6a6d7fbe123b93f5d399259f98bc2e60e Mon Sep 17 00:00:00 2001 From: Robin Jacobs Date: Fri, 17 Jul 2020 12:05:03 +0100 Subject: [PATCH] Add a Dockerfile to allow running Telegram-React inside a container --- .dockerignore | 5 +++++ Dockerfile | 27 +++++++++++++++++++++++++++ README.md | 12 ++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..74d7adb6c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +node_modules +.env +.idea +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..830c3e057 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM node:14 AS build + +WORKDIR /app/ + +# Copy over package.json and package-lock.json and install dependencies first, +# so that we don't need to re-download dependencies if they have not been modified. +COPY package.json package-lock.json ./ +RUN npm ci + +COPY . . +RUN cp -v node_modules/tdweb/dist/* public/ + +ARG TELEGRAM_API_ID +ENV REACT_APP_TELEGRAM_API_ID=${TELEGRAM_API_ID} +ARG TELEGRAM_API_HASH +ENV REACT_APP_TELEGRAM_API_HASH=${TELEGRAM_API_HASH} + +RUN npm run build + +FROM nginx:stable + +WORKDIR /usr/share/nginx/html/ +COPY --from=build /app/build/ . + +# Hack to get around the hardcoded folder structure without requiring the user to +# go to /telegram-react in their browser +RUN ln -s . telegram-react diff --git a/README.md b/README.md index 03176431b..f2d223a43 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,18 @@ Define its value to be the string `http://{username}.github.io/{repo-name}`, whe ``` $ npm run deploy ``` + +### Running in a Docker container + +In order to run Telegram-React inside a Docker container, you need to provide your Telegram API key as build arguments. + +``` +docker build . --build-arg TELEGRAM_API_ID=0000000 --build-arg TELEGRAM_API_HASH=00000000000000000 +``` +Replace these values with your own Telegram API key information, which you can obtain [here](https://my.telegram.org/apps). + +The Docker build will perform all the necessary steps to get a working build of Telegram-React. + ### References 1. [Deploying a React App (created using create-react-app) to GitHub Pages](https://github.com/gitname/react-gh-pages)