Skip to content

Commit 0da26be

Browse files
committed
Multiple improvements
1 parent 707536b commit 0da26be

9 files changed

Lines changed: 192 additions & 126 deletions

File tree

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# docker buildx build -t filesync:latest --compress --load .
2-
# docker buildx build --platform linux/amd64 -t filesync --compress --output=type=docker,dest=./filesync.tar .
1+
# Development
2+
# docker buildx build -t filesync:latest --load .
3+
# docker buildx build --platform linux/amd64 -t filesync --output=type=docker,dest=filesync.tar .
34

45
# ==============================
56
# Stage 1: Build Python dependencies

README.md

Lines changed: 109 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,86 +20,160 @@
2020

2121
</div>
2222

23-
## Install
23+
# Installation
2424

25-
**1. Download required files**
25+
## Prerequisites
2626

27-
Get the `docker-compose.yml` and `Caddyfile` from the **deploy** folder.
27+
- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed
28+
- Python 3 (for generating the secret key)
2829

29-
**2. Generate a secure secret key**
30+
## Quick Start
3031

31-
Run the following command to generate a 32-byte base64-encoded secret:
32+
### Option 1: HTTP (Local Development)
3233

33-
```
34-
python3 -c "import secrets, base64; print(base64.b64encode(secrets.token_bytes(32)).decode())"
35-
```
34+
**1. Download the required files**
3635

37-
**3. Configure the secret key**
36+
Get [docker-compose.yml](deploy/docker-compose.yml) from the `deploy` folder.
3837

39-
Open `docker-compose.yml` and replace **both occurrences** of `<SECRET_KEY>` with the generated value from the previous step.
38+
**2. Generate a secret key**
4039

41-
**Example:**
40+
Run the following command to generate a secure 32-byte base64-encoded secret:
4241

42+
```bash
43+
python3 -c "import secrets, base64; print(base64.b64encode(secrets.token_bytes(32)).decode())"
4344
```
45+
46+
**3. Configure the secret**
47+
48+
Open `docker-compose.yml` and replace **both occurrences** of `<SECRET_KEY>` with the generated value.
49+
50+
Example:
51+
```yaml
4452
...
4553
- --static-auth-secret=/RaFOHJQQPAAXRNdaDhfBghvX9+o9UJEazKgIopK3TI=
4654
...
4755
- SECRET_KEY=/RaFOHJQQPAAXRNdaDhfBghvX9+o9UJEazKgIopK3TI=
4856
...
4957
```
5058

51-
**4. (Optional) Enable HTTPS**
59+
**4. Start FileSync**
60+
61+
```bash
62+
docker-compose up -d
63+
```
64+
65+
Access FileSync at `http://localhost:80`
66+
67+
### Option 2: HTTPS (Production with Custom Domain)
68+
69+
**1. Download the required files**
5270

53-
To enable HTTPS, edit the `Caddyfile`:
71+
Get [docker-compose-ssl.yml](deploy/docker-compose-ssl.yml) and [Caddyfile](deploy/Caddyfile) from the `deploy` folder.
5472

55-
- Replace `:80` with your domain (e.g., `filesync.app`).
73+
**2. Generate a secret key**
74+
75+
Run the following command to generate a secure 32-byte base64-encoded secret:
76+
77+
```bash
78+
python3 -c "import secrets, base64; print(base64.b64encode(secrets.token_bytes(32)).decode())"
79+
```
80+
81+
**3. Configure the secret**
82+
83+
Open `docker-compose-ssl.yml` and replace **both occurrences** of `<SECRET_KEY>` with the generated value.
84+
85+
Example:
86+
```yaml
87+
...
88+
- --static-auth-secret=/RaFOHJQQPAAXRNdaDhfBghvX9+o9UJEazKgIopK3TI=
89+
...
90+
- SECRET_KEY=/RaFOHJQQPAAXRNdaDhfBghvX9+o9UJEazKgIopK3TI=
91+
...
92+
```
5693

57-
Caddy will automatically provision and renew SSL certificates for your domain.
94+
**4. Configure your domain**
5895

59-
**Example:**
96+
Open `Caddyfile` and replace `yourdomain.com` with your actual domain.
6097

98+
Example:
6199
```
62100
filesync.app {
63101
reverse_proxy filesync:80
64102
}
65103
```
66104

67-
**5. Start the services**
68-
69-
Run the following command to start everything in detached mode:
105+
**5. Start FileSync**
70106

71-
```
72-
docker-compose up -d
107+
```bash
108+
docker-compose -f docker-compose-ssl.yml up -d
73109
```
74110

75-
**6. Access the application**
111+
Caddy will automatically obtain and manage SSL certificates from Let's Encrypt.
76112

77-
Once the services are up;
113+
Access FileSync at `https://yourdomain.com`
78114

79-
- For local testing, open your browser at:
115+
## Stopping FileSync
80116

81-
```
82-
http://localhost
117+
```bash
118+
# For HTTP setup
119+
docker-compose down
120+
121+
# For HTTPS setup
122+
docker-compose -f docker-compose-ssl.yml down
83123
```
84124

85-
- If using a domain, open:
125+
## Required Ports
86126

87-
```
88-
https://yourdomain
89-
```
127+
To expose FileSync to the internet, ensure the following ports are open on your server/firewall:
128+
129+
### HTTP Setup
130+
- **Port 80** (TCP) - Web interface
131+
- **Port 3478** (TCP + UDP) - STUN/TURN server for WebRTC
132+
133+
### HTTPS Setup
134+
- **Port 443** (TCP) - Web interface (HTTPS)
135+
- **Port 3478** (TCP + UDP) - STUN/TURN server for WebRTC
136+
137+
> **Note:** Port 3478 is essential for establishing peer-to-peer connections, especially when devices are behind NAT/firewalls.
138+
139+
## Customizing Ports
90140

91-
## Uninstall (Optional)
141+
### Changing the HTTP Port
92142

93-
To stop and remove the containers, run:
143+
By default, FileSync uses port 80. To use a different port (e.g., 8080):
94144

145+
**1. Edit `docker-compose.yml`**
146+
147+
Find the `ports` section under the `filesync` service:
148+
149+
```yaml
150+
ports:
151+
- "80:80"
95152
```
96-
docker-compose down
153+
154+
Change the **first** port number to your desired port:
155+
156+
```yaml
157+
ports:
158+
- "8080:80"
97159
```
98160
161+
**2. Access FileSync**
162+
163+
Access FileSync at `http://localhost:8080` (or your server IP with the new port).
164+
165+
> **Note:** The second port number (80) should remain unchanged as it refers to the internal container port.
166+
167+
### Changing the HTTPS Port
168+
169+
To use a custom external port, deploy a separate reverse proxy (Nginx, Traefik, or standalone Caddy) that:
170+
- Listens on port 443 with SSL termination
171+
- Forwards traffic to FileSync on your custom internal HTTP port
172+
173+
This approach maintains standard HTTPS on port 443 while allowing flexible internal port configuration.
174+
99175
## Under the hood
100176

101177
FileSync uses [PeerJS](https://github.com/peers/peerjs) (a WebRTC wrapper) to transfer files between multiple devices. Files shared are peer-to-peer, which means there is a direct file transfer between the sender and receiver without any intermediate server. Your files remain private and secure throughout the entire transfer process.
102178

103-
Do note that a [PeerJS server](https://github.com/peers/peerjs-server) is used to assist in the initial connection setup, ensuring all users can establish peer-to-peer connections effectively. Once the connections are established, the server steps back, allowing the direct transfer of files between the sender and the receiver. At no point during this process does the server have access to the file contents. It solely facilitates the connection between users without compromising the privacy or security of the files being shared.
104-
105179
![File Transfer - https://xkcd.com/949](web/assets/comic.png)

deploy/Caddyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
:80 {
1+
yourdomain.com {
22
reverse_proxy filesync:80
33
}

deploy/docker-compose-ssl.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
services:
2+
caddy:
3+
image: caddy
4+
container_name: filesync-caddy
5+
ports:
6+
- "443:443"
7+
volumes:
8+
- ./Caddyfile:/etc/caddy/Caddyfile:ro
9+
- filesync:/data
10+
depends_on:
11+
- filesync
12+
restart: unless-stopped
13+
14+
filesync:
15+
image: poliuscorp/filesync
16+
container_name: filesync-app
17+
environment:
18+
- SECRET_KEY=<SECRET_KEY>
19+
depends_on:
20+
- peerjs
21+
restart: unless-stopped
22+
23+
peerjs:
24+
image: peerjs/peerjs-server:1.1.0-rc.2
25+
container_name: filesync-peerjs
26+
command: peerjs --path /peerjs
27+
depends_on:
28+
- coturn
29+
restart: unless-stopped
30+
31+
coturn:
32+
image: coturn/coturn:alpine
33+
container_name: filesync-coturn
34+
command:
35+
- --fingerprint
36+
- --use-auth-secret
37+
- --no-multicast-peers
38+
- --realm=filesync.app
39+
- --static-auth-secret=<SECRET_KEY>
40+
ports:
41+
- "3478:3478/tcp"
42+
- "3478:3478/udp"
43+
restart: unless-stopped
44+
45+
volumes:
46+
filesync:

deploy/docker-compose.yml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
services:
2-
caddy:
3-
image: caddy
4-
container_name: filesync-caddy
2+
filesync:
3+
image: poliuscorp/filesync
4+
container_name: filesync-app
5+
environment:
6+
- SECRET_KEY=<SECRET_KEY>
57
ports:
68
- "80:80"
7-
- "443:443"
8-
volumes:
9-
- ./Caddyfile:/etc/caddy/Caddyfile:ro
10-
- filesync:/data
9+
depends_on:
10+
- peerjs
11+
restart: unless-stopped
12+
13+
peerjs:
14+
image: peerjs/peerjs-server:1.1.0-rc.2
15+
container_name: filesync-peerjs
16+
command: peerjs --path /peerjs
17+
depends_on:
18+
- coturn
1119
restart: unless-stopped
1220

1321
coturn:
@@ -22,20 +30,4 @@ services:
2230
ports:
2331
- "3478:3478/tcp"
2432
- "3478:3478/udp"
25-
restart: unless-stopped
26-
27-
peerjs:
28-
image: peerjs/peerjs-server:1.1.0-rc.2
29-
container_name: filesync-peerjs
30-
command: peerjs --path /peerjs
31-
restart: unless-stopped
32-
33-
filesync:
34-
image: poliuscorp/filesync
35-
container_name: filesync-app
36-
environment:
37-
- SECRET_KEY=<SECRET_KEY>
38-
restart: unless-stopped
39-
40-
volumes:
41-
filesync:
33+
restart: unless-stopped

web/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ <h5 style="color: var(--color-h1); margin:0">
419419
<script src="js/vendors/bootstrap.bundle.min.js" type="text/javascript"></script>
420420
<script src="js/vendors/jszip.min.js" type="text/javascript"></script>
421421
<script src="js/vendors/qrious.min.js" type="text/javascript"></script>
422-
<script src="js/vendors/crypto-js.min.js" type="text/javascript"></script>
423422
<script src="js/vendors/peerjs.min.js" type="text/javascript"></script>
424423
<script type="module" src="js/modules/dom.js" type="text/javascript"></script>
425424
<script type="module" src="js/modules/script.js" type="text/javascript"></script>

0 commit comments

Comments
 (0)