Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #305 from mgilangjanuar/staging
Browse files Browse the repository at this point in the history
Release v2.1.0
  • Loading branch information
mgilangjanuar authored Apr 10, 2022
2 parents 9ae5017 + 05e0009 commit 65569e6
Show file tree
Hide file tree
Showing 32 changed files with 893 additions and 129 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist/
build/
keys
.env
*.env
.vercel
lab/
sessions/
Expand Down
1 change: 1 addition & 0 deletions docker/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ENV=develop

TG_API_ID=
TG_API_HASH=
ADMIN_USERNAME=

DB_PASSWORD=

Expand Down
6 changes: 4 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ services:
traefik.http.routers.server.rule: Host(`teledrive.localhost`)
traefik.port: 4000
ports:
- "4000:4000"
- "${PORT:-4000}:${PORT:-4000}"
expose:
- 4000
- ${PORT:-4000}
build:
context: ../.
dockerfile: Dockerfile
Expand All @@ -26,6 +26,7 @@ services:
- .env
depends_on:
- db
- redis

db:
image: postgres:13
Expand All @@ -37,6 +38,7 @@ services:
volumes:
- teledrive_data:/var/lib/postgresql/data
- ../server/src/model/migrations/dump.sql:/docker-entrypoint-initdb.d/dump.sql
- ../server/src/model/migrations/dump.20220406.sql:/docker-entrypoint-initdb.d/dump.20220406.sql

redis:
image: redis:6
Expand Down
128 changes: 128 additions & 0 deletions docs/blog/2022-04-08-upgrade-210.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
slug: upgrade-210
title: Upgrade to 2.1.0
author: M Gilang Januar
author_title: The Creator
author_url: https://github.com/mgilangjanuar
author_image_url: https://avatars.githubusercontent.com/u/3146378?v=4
tags: [releases]
---

## What's New?

- Users Management (Admin Panel)

![](./SCR-20220408-nvj.png)

## Upgrade Guide

### 1. Pull from GitHub

```shell
git reset --hard
git clean -f
git pull origin main
```

### 2. Update variables

There's a new environment variable that you can added to your application:

- `ADMIN_USERNAME`: this variable is used for login to the admin panel.

Select how you install your application to update your environment variable:

- Manual installation:

Add `ADMIN_USERNAME` to `server/.env` file:

```shell
echo "ADMIN_USERNAME=your_telegram_username" >> server/.env
```

- Docker installation:

Add `ADMIN_USERNAME` to `docker/.env` file:

```shell
echo "ADMIN_USERNAME=your_telegram_username" >> docker/.env
```

- Heroku:

```shell
heroku config:set ADMIN_USERNAME=your_telegram_username
```

- Vercel:

Go to the dashboard, select your project, and go to the **Settings > Environment Variables**. Then, add key: `ADMIN_USERNAME` and value: `your_telegram_username`.

### 3. Update database

There's a new SQL file that you have to migrate to your database:
- `dump.20220406.sql`
Select how you install your application to update your database schema:
- Manual installation:
```shell
psql teledrive < ./server/src/model/migrations/dump.20220406.sql
```
**Note.** *Change `teledrive` with your database name.*
- Docker installation:
*Not needed. Automatically migrated after rebuild.*
- Heroku:
```shell
heroku pg:psql --app YOUR_APP_NAME -f ./server/src/model/migrations/dump.20220406.sql
```
**Note.** *Change `YOUR_APP_NAME` to your application name.*
### 4. Rebuild and run
Select how you deploy your application to rebuild the application:
- Manual installation:
```shell
yarn install
yarn workspaces run build
cd server && node dist/index.js
```
- Docker installation:
```shell
cd docker
docker-compose down
docker-compose up --build --force-recreate -d
docker image prune -f # remove dangling images
```
- Heroku:
```shell
git push heroku main
```
- Vercel:
```shell
yarn install
yarn workspaces run build
vercel --prod
```
## Frequiently Asked Questions
*Q: How to change the default port?*
A: You can change the default port by update/add `PORT=80` to your `server/.env` file if you installed manually. Or, in `docker/.env` file if you installed with Docker. Then, you need to [rebuild](#4-rebuild-and-run) the application to apply the changes.
Binary file added docs/blog/SCR-20220408-nvj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions docs/docs/Deployment/heroku.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,38 @@ Get started by build all needed services.

```shell
heroku config:set USE_PSQL_HEROKU=1
heroku config:set DATABASE_URL=[YOUR_DB_CONNECTION_URI]
heroku config:set DATABASE_URL=YOUR_DB_CONNECTION_URI
```

**Note.** *Change `YOUR_DB_CONNECTION_URI` to your database connection URI.*

- Import dump.sql

```shell
heroku pg:psql --app [YOUR_APP_NAME] -f ./server/src/model/migrations/dump.sql
heroku pg:psql --app YOUR_APP_NAME -f ./server/src/model/migrations/dump.sql
heroku pg:psql --app YOUR_APP_NAME -f ./server/src/model/migrations/dump.20220406.sql
```

**Note.** *Change `YOUR_APP_NAME` to your application name from Heroku.*

### Provide environment variables

Set all variables with your own values to Heroku:

```shell
heroku config:set [ENV_NAME]=[ENV_VALUE]
heroku config:set ENV_NAME=ENV_VALUE
```

**Note.** *Change `ENV_NAME` and `ENV_VALUE` to your value as defined below.*

- Define all server variables

| env | required | description |
| ---------------------- | -------- | ----------------------------------------------------- |
| ENV | no | Hide the logs for production, default: develop |
| TG_API_ID | yes | Application ID from your Telegram App |
| TG_API_HASH | yes | Application hash from Telegram App |
| ADMIN_USERNAME | yes | Telegram username of the admin TeleDrive |
| DATABASE_URL | yes | PostgreSQL connection URI, format: `postgresql://[user]:[password]@[host]:[port][/dbname][?paramspec]` |
| API_JWT_SECRET | yes | Random string for encrypt JWT web token |
| FILES_JWT_SECRET | yes | Random string for encrypt public files |
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/Deployment/nginx.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ upstream teledrive {
}
server{
server_name [your-domain-name.com]; # your domain name
server_name your-domain-name.com; # change to your domain name
send_timeout 60m;
client_header_timeout 60m;
Expand Down
8 changes: 5 additions & 3 deletions docs/docs/Installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ Get started by installing all needed services and define all variables.
| env | required | description |
| ---------------------- | -------- | ----------------------------------------------------------------- |
| ENV | no | Hide the logs for production, default: develop |
| PORT | no | Set custom application port for running, default: 4000 |
| TG_API_ID | yes | Application ID from your Telegram App |
| TG_API_HASH | yes | Application hash from Telegram App |
| ADMIN_USERNAME | yes | Telegram username of the admin TeleDrive |
| DB_PASSWORD | yes | Database password |
| API_JWT_SECRET | yes | Random string for encrypt JWT web token |
| FILES_JWT_SECRET | yes | Random string for encrypt public files |
Expand Down Expand Up @@ -63,12 +65,12 @@ docker-compose down
Upgrade to the latest version of TeleDrive with this command:

```shell
git pull origin main # or, staging for the latest updates
git pull origin main # or, staging for the latest updates
cd docker
docker-compose down
docker-compose build teledrive
docker-compose up -d
docker-compose up --build --force-recreate -d
docker image prune -f # remove dangling images
```

## Common Issues
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/Installation/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Get started by installing all needed services and define all variables.
| PORT | no | Port for running API, default: 4000 |
| TG_API_ID | yes | Application ID from your Telegram App |
| TG_API_HASH | yes | Application hash from Telegram App |
| ADMIN_USERNAME | yes | Telegram username of the admin TeleDrive |
| DATABASE_URL | yes | PostgreSQL connection URI, format: `postgresql://[user]:[password]@[host]:[port][/dbname][?paramspec]` |
| API_JWT_SECRET | yes | Random string for encrypt JWT web token |
| FILES_JWT_SECRET | yes | Random string for encrypt public files |
Expand Down Expand Up @@ -100,6 +101,7 @@ You need to create and import the database schema.

```shell
psql teledrive < ./server/src/model/migrations/dump.sql
psql teledrive < ./server/src/model/migrations/dump.20220406.sql
```

Sometimes, we need to copy the dump file to the `/var/lib/postgresql` directory first:
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ sidebar_position: 1

# Introduction

- version: 2.1.0
- updated: 2022-04-08

If you ever heard about cloud storage services like Google Drive, OneDrive, iCloud, Dropbox &mdash; **TeleDrive** is one of them, you can upload photos, videos, documents, or any files for free. But, what makes **TeleDrive** different? We're using the <a href="https://core.telegram.org/api#telegram-api" target="_blank">Telegram API</a>, so you can do uploads without limit and free.

## Prerequisite
Expand Down
2 changes: 1 addition & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const config = {
position: 'left',
label: 'Getting Started',
},
// {to: '/blog', label: 'Blog', position: 'left'},
{to: '/blog', label: 'Blog', position: 'left'},
{
href: 'https://github.com/mgilangjanuar/teledrive',
label: 'GitHub',
Expand Down
49 changes: 49 additions & 0 deletions install.docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

if [ ! -f docker/.env ]
then
echo "Generating .env file..."

ENV="develop"

echo "Preparing your keys from https://my.telegram.org/"
read -p "Enter your TG_API_ID: " TG_API_ID
read -p "Enter your TG_API_HASH: " TG_API_HASH

echo
read -p "Enter your ADMIN_USERNAME: " ADMIN_USERNAME
read -p "Enter your PORT: " PORT
PORT="${PORT:=4000}"

DB_PASSWORD=$(openssl rand -hex 18)
API_JWT_SECRET=$(openssl rand -base64 36)
FILES_JWT_SECRET=$(openssl rand -base64 36)

echo "ENV=$ENV" > docker/.env
echo "PORT=$PORT" >> docker/.env
echo "TG_API_ID=$TG_API_ID" >> docker/.env
echo "TG_API_HASH=$TG_API_HASH" >> docker/.env
echo "ADMIN_USERNAME=$ADMIN_USERNAME" >> docker/.env
echo "DB_PASSWORD=$DB_PASSWORD" >> docker/.env
echo "API_JWT_SECRET=$API_JWT_SECRET" >> docker/.env
echo "FILES_JWT_SECRET=$FILES_JWT_SECRET" >> docker/.env

cd docker
docker-compose up -d
sleep 2
docker-compose up -d
else
git reset --hard
git clean -f
git pull origin main

export $(cat docker/.env | xargs)

cd docker
docker-compose down
docker-compose up --build --force-recreate -d
sleep 2
docker-compose up -d

docker image prune -f
fi
Loading

0 comments on commit 65569e6

Please sign in to comment.