Skip to content

Commit

Permalink
Add a Dockerfile to allow running Telegram-React inside a container
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinJ1995 committed Jul 23, 2020
1 parent 6bbfe23 commit d49112f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
node_modules
.env
.idea
Dockerfile
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d49112f

Please sign in to comment.