Skip to content

Commit 01d8669

Browse files
committed
Now run pygmy in Docker, pushed image @amit19/pygmy
1 parent d7b7deb commit 01d8669

File tree

4 files changed

+55
-48
lines changed

4 files changed

+55
-48
lines changed

Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM ubuntu:18.04
2+
3+
LABEL name='pygmy'
4+
LABEL version='1.0.0'
5+
LABEL description='Pygmy(pygy.co) URL shortener'
6+
LABEL vendor="Amit Tripathi"
7+
8+
RUN apt update -y && apt install python3-pip -y
9+
10+
WORKDIR /pygmy
11+
ADD . /pygmy
12+
RUN pip3 install -r requirements.txt
13+
14+
EXPOSE 8000
15+
16+
CMD ["python3", "run.py"]

README.md

+37-45
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<p align="center"><img src="pygmyui/static/logo/logov2.png" alt="pygmy" height="200px"></p>
22

3-
Pygmy
4-
=====
3+
# Pygmy
4+
55

66
[![Build Status](https://travis-ci.org/amitt001/pygmy.svg?branch=master)](https://travis-ci.org/amitt001/pygmy)
77

@@ -14,7 +14,7 @@ Check link stats by adding **+** to the URL. Example [pygy.co/pygmy+](https://py
1414
- [Table of Contents](#table-of-contents)
1515
- [Features](#features)
1616
- [Technical Info](#technical-info)
17-
- [Installaton/Setup](#installatonsetup)
17+
- [Installation/Setup](#installationsetup)
1818
- [DB Setup:](#db-setup)
1919
- [Use MySQL](#use-mysql)
2020
- [Use Postgresql](#use-postgresql)
@@ -39,8 +39,7 @@ The architecture is very loosely coupled which allows custom integrations easily
3939
- A REST API on top. Uses Flask framework
4040
- The UI layer for rendering the UI. It uses Django framework
4141

42-
Features
43-
========
42+
## Features
4443

4544
- URL shortner
4645
- Customized short URL's(ex: `pygy.co/pygmy`)
@@ -50,47 +49,48 @@ Features
5049
- User dashboard
5150
- Link Analytics(add + to the tiny URL to get link stats)
5251

53-
Technical Info
54-
==============
52+
## Technical Info
5553

5654
- Python 3, Javascript, JQuery, HTML, CSS
5755
- REST API: Flask
5856
- Pygmyui: Django(It serves the web user interface)
5957
- DB: PostgreSQL/MySQL/SQLite
6058
- Others: SQLAlchmey, JWT
59+
- Docker
60+
61+
## Installation/Setup
6162

62-
Installation/Setup
63-
=================
63+
### Docker
6464

65-
NOTE: **This module only supports Python 3. Make sure pip and virtualenv are both python 3 based versions.**
66-
**To install Python 3 on Mac: http://docs.python-guide.org/en/latest/starting/install3/osx/**
65+
1. `docker run -it -p 8000:8000 amit19/pygmy`
66+
2. Open http://localhost:8000 in your browser
67+
68+
### Manual(from source)
6769

6870
1. Clone `git clone https://github.com/amitt001/pygmy.git & cd pygmy`
6971
2. (Optional) Install virtualenv (optional but recommended)
7072
- `virtualenv -p python3 env`
7173
- `source env/bin/activate`
7274
3. Install dependencies: `pip3 install -r requirements.txt` (if you are using MySQL or PostgreSQL check [DB setup](#db-setup) section)
73-
4. `cd src`
74-
5. `python run.py` (It runs Flask and Django servers using gunicorn)
75-
6. Visit `127.0.0.1:8000` to use the app
76-
7. Logs can be viewed at `pygmy/data/pygmy.log`
75+
4. `python run.py` (It runs Flask and Django servers using gunicorn)
76+
5. Visit `127.0.0.1:8000` to use the app
77+
6. Logs can be viewed at `pygmy/data/pygmy.log`
7778

7879
Note:
7980

80-
1. The project has two config files:
81+
- **This module only supports Python 3. Make sure pip and virtualenv are both python 3 based versions.**(To install Python 3 on Mac: http://docs.python-guide.org/en/latest/starting/install3/osx/)
82+
- The project has two config files:
8183
- pygmy.cfg: `pygmy/config/pygmy.cfg` rest API and pygmy core settings file
8284
- settings.py: `pygmyui/pygmyui/settings.py` Django settings file
83-
2.Both the files have aparallel <name>_test.<ext> config files to configure it for tests.
84-
2. SQLite is default db, if you are using PostgreSQL or MySQL with this project, make sure they are installed into the system.
85-
3. To modify config settings vim `pygmy/config/pygmy.cfg`
86-
4. You can run pygmy shell present in src directory to run the program on terminal. `python shell`
87-
5. By default in `pygmyui/pygmyui/settings.py` DEBUG is set to True, set it to False in production
85+
- Both the files have aparallel <name>_test.<ext> config files to configure it for tests.
86+
- SQLite is default db, if you are using PostgreSQL or MySQL with this project, make sure they are installed into the system.
87+
- To modify config settings vim `pygmy/config/pygmy.cfg`
88+
- You can run pygmy shell present in src directory to run the program on terminal. `python shell`
89+
- By default in `pygmyui/pygmyui/settings.py` DEBUG is set to True, set it to False in production
8890

89-
DB Setup:
90-
=========
91+
## DB Setup:
9192

92-
Use MySQL
93-
---------
93+
### Use MySQL
9494

9595
First install `pymysql`:
9696

@@ -113,22 +113,19 @@ Enter MySQL URL
113113

114114
Note: Better using Mysql with version > `5.6.5` to use default value of `CURRENT_TIMESTAMP` for `DATETIME`.
115115

116-
Use Postgresql
117-
--------------
116+
### Use Postgresql
118117

119118
`pip install psycopg2`
120119

121120
`postgres://[email protected]:5432/pygmy`
122121

123-
Use SQLite
124-
----------
122+
### Use SQLite
125123

126124
SQLite is natively supported in Python
127125

128126
`sqlite:////var/lib/pygmy/pygmy.db`
129127

130-
Using Pygmy API
131-
===============
128+
## Using Pygmy API
132129

133130
Create User:
134131
------------
@@ -141,6 +138,8 @@ Create User:
141138
}'
142139

143140

141+
*To be updated soon*
142+
144143
Get User:
145144

146145
Get All User Link:
@@ -149,8 +148,7 @@ Create Link:
149148

150149
Get Link:
151150

152-
Shell Usage
153-
===========
151+
## Shell Usage
154152

155153
Open shell using ./shell. Available context is pygmy, Config, DB, etc. See all context by using pygmy_context.
156154

@@ -224,18 +222,15 @@ Docstring:
224222
URL value.
225223
```
226224

227-
How Link Stats Are Generated?
228-
=============================
225+
###### How Link Stats Are Generated?
229226

230227
For getting geo location stats from IP maxminds' [GeoLite2-Country.mmd](http://pygy.co/cm) database is used. It's in `pygmy/app` directory.
231228

232-
How Pygmy Auth Token Works?
233-
===========================
229+
###### How Pygmy Auth Token Works?
234230

235231
It uses JWT. When user logs in using username and password two tokens are generated, refresh token and auth token. Auth token is used for authentication with the Pygmy API. Refresh token can only be used to generate new auth token. Auth token has a very short TTL but refresh token has a longer TTL. After 30 minutes. When a request comes with the old auht token and a new token is generated from the refresh token API. User passwords are encrypted by [bcrypt](https://en.wikipedia.org/wiki/Bcrypt) hash algorithm.
236232

237-
Development
238-
===========
233+
## Development
239234

240235
If you find any bug, have a question or a general feature request. Open an issue on the 'Issue' page.
241236

@@ -247,20 +242,17 @@ See coverage report(Coverage is bad because the coverage for integration tests i
247242

248243
`coverage report`
249244

250-
Contributions
251-
=============
245+
## Contributions
252246

253247
Thanks [batarian71](https://github.com/batarian71) for providing the logo icon.
254248

255-
Sponsorship
256-
===========
249+
## Sponsorship
257250

258251
I would like to thank DigitalOcean for providing initial hosting to Pygmy project. Pygy.co is hosted on DigitalOcean.
259252

260253
<a href="https://www.digitalocean.com/"><img src="https://i.imgur.com/6cYodyH.png"></a>
261254

262-
License
263-
=======
255+
## License
264256

265257
MIT License
266258

run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
PYGMY_API_ARGS = ['gunicorn', '-b 127.0.0.1:9119', '-w 1', 'pygmy.rest.wsgi:app']
11-
PYGMYUI_ARGS = ['gunicorn', '-b 127.0.0.1:8000', '-w 1', 'pygmyui.wsgi']
11+
PYGMYUI_ARGS = ['gunicorn', '-b 0.0.0.0:8000', '-w 1', 'pygmyui.wsgi']
1212
process = []
1313

1414

tests/fixture.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import atexit
44
import pytest
55
import subprocess
6-
import coverage.data
76

87
__all__ = [
98
'run_test_server',
@@ -19,7 +18,7 @@ class PygmyApiTestServer:
1918
@classmethod
2019
def start_pygmy_api_server(cls):
2120
# os.chdir('src')
22-
command = ['coverage', 'run', 'pygmy_api_run.py', 'test']
21+
command = ['python', 'pygmy_api_run.py', 'test']
2322
fobj = open(_PYGMY_SUBPROCESS_LOG_FILE, 'w')
2423
cls.pygmyapi_proc = subprocess.Popen(
2524
command, stdout=fobj, stderr=fobj)

0 commit comments

Comments
 (0)