Skip to content

Commit

Permalink
Merge pull request #269 from marudhu2004/add_docker
Browse files Browse the repository at this point in the history
Adding docker to the project
  • Loading branch information
kgashok authored Dec 2, 2023
2 parents 2b4a4cb + 7a3642f commit f451e53
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.circleci
.github
env
conf
conf_template
docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__/
.vscode/
Logfile
Logfile.log
conf
11 changes: 11 additions & 0 deletions DOCKER_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
copy the folder named "conf_template" and name it "conf".
update the env files under conf with your keys.
run "docker compose up -d --build" to run the project.
wait for a minute and restart any container that stops.

additional:
login in to pgadmin and connect to the database server.
for the host name use local_pgdb.

Note:
please run "docker compose up -d --build" when you update environment variables.
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:18.04

# Installing python
RUN apt-get update
RUN apt-get install -y libpq-dev
RUN apt-get install -y python3-dev
RUN apt-get install -y python3-pip
RUN apt-get clean

RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade pillow

WORKDIR /saythanks

# Installing requirements
COPY ./requirements.txt .
RUN python3 -m pip install -r requirements.txt

# Copying the app
COPY . .

EXPOSE 5000
CMD [ "python3", "t.py" ]
3 changes: 3 additions & 0 deletions conf_template/db.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POSTGRES_DB=saythanks
POSTGRES_USER=user-name
POSTGRES_PASSWORD=strong-password
2 changes: 2 additions & 0 deletions conf_template/pgadmin.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PGADMIN_DEFAULT_EMAIL=[email protected]
PGADMIN_DEFAULT_PASSWORD=strong-password
7 changes: 7 additions & 0 deletions conf_template/site.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DATABASE_URL='postgresql://user-name:strong-password@your-IP-addr/saythanks'
SENDGRID_API_KEY=''
AUTH0_CLIENT_ID=''
AUTH0_CLIENT_SECRET=''
AUTH0_CALLBACK_URL='http://localhost:5000/callback'
AUTH0_DOMAIN=''
AUTH0_JWT_V2_TOKEN=''
49 changes: 49 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: "3.8"
services:

site:
build: .
ports:
- 5000:5000
env_file:
- ./conf/site.env
volumes:
- ./:/saythanks
depends_on:
- db

db:
image: postgres
container_name: local_pgdb
restart: always
ports:
- "5432:5432"
env_file:
- ./conf/db.env
volumes:
- local_pgdata:/var/lib/postgresql/data
- ./saythanks/sqls/schema.sql:/docker-entrypoint-initdb.d/schema.sql
networks:
- saythanks

pgadmin:
image: dpage/pgadmin4
container_name: pgadmin4_container
restart: always
ports:
- "8888:80"
env_file:
- ./conf/pgadmin.env

volumes:
- pgadmin-data:/var/lib/pgadmin

networks:
- saythanks

volumes:
local_pgdata:
pgadmin-data:

networks:
saythanks:
47 changes: 47 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
appdirs
auth0-python<=2
blinker
click
colorama
contextlib2
crayons
dateparser
docopt
flake8
flask
flask-qrcode
gunicorn
humanize
itsdangerous
jinja2
lxml
markupsafe
maya
names
ordereddict
packaging
pendulum
psycopg2
pyjwt
pyment
pytest
pyparsing
pytest-cov
python-dateutil
python-http-client
pytz
pytzdata
raven
regex
requests
ruamel.yaml
sendgrid
six
sqlalchemy
tablib
tzlocal
werkzeug
whitenoise
python-dotenv
markdown
flask_common
2 changes: 1 addition & 1 deletion t.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
is_test_run = 'TEST' in os.environ

if __name__ == '__main__' and not is_test_run:
saythanks.app.run()
saythanks.app.run(host='0.0.0.0', port=5000)

0 comments on commit f451e53

Please sign in to comment.