Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# official python image
FROM python:3.9-slim

# setting working dir
WORKDIR /localfiletransfer

# copy flask app in to the container
COPY . /localfiletransfer

# installing requirements
RUN pip install --no-cache-dir -r requirements.txt

# exposing port 5000
EXPOSE 5000

# command to run the app
CMD [ "python3", "app.py" ]
12 changes: 3 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,10 @@ def download_file(filename):
return response

def get_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# doesn't even have to be reachable
s.connect(('10.255.255.255', 1))
IP = s.getsockname()[0]
except Exception:
IP = '127.0.0.1'
finally:
s.close()
return IP
return socket.gethostbyname("host.docker.internal") # Host IP For macOS and Windows
except:
return socket.gethostbyname(socket.gethostname()) # Host IP For Linux

def generate_qr_code(url):
qr = qrcode.QRCode(
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3.9'

services:

web_windows: # service for Windows/Mac
build: .
volumes:
- ./uploads:/localfiletransfer/uploads
- ./downloads:/localfiletransfer/downloads
ports:
- "5000:5000" # Required for macOS/Windows to expose the container port
profiles:
- "windows_mac" # Profile name for macOS/Windows

web_linux: # service for Linux
build: .
volumes:
- ./uploads:/localfiletransfer/uploads
- ./downloads:/localfiletransfer/downloads
network_mode: "host" # Linux host network mode
profiles:
- "linux" # Profile name for Linux