- Shortify one userspace
- tify your way
- Shortify valid urls using sliced md5 hash
tify.one/hash
shortified url to redirecttify.one
redirects toapp.tify.one
bad hash
shows404
pageapp.tify.one
to access the home page and full functionalityblog.tify.one
to access the bloghelp.tify.one
user.tify.one
the user space shotified profile and urls i.e.user.tify.one/bio
for general profile oruser.tify.one/ig
for specific custom links
- Development environment with Docker and Docker Compose
- Namecheap
- DigitalOcean
- ssl Certbot
- ssh
- datadog
- nginx
docker build -t sh-py:1.0 .
docker run -d -it --rm -p 8000:8000 --name sh-py-0 -v /home/ralex/code/shortener:/code sh-py:1.0
docker exec -it sh-py-0 sh
python manage.py runserver 0.0.0.0:8000
python manage.py makemigrations
python manage.py migrate
python manage.py runserver 0.0.0.0:8000
python manage.py createsuperuser
admin.tify.one
- add to
settings.py
the Schema for for all objects types
GRAPHENE = {
'SCHEMA': 'shortener.schema.schema'
}
- using
md5
fromhashlib
mutation {
createUrl(urlFull:"https://ralex.me") {
url {
id
urlFull
urlHash
visits
dateCreated
}
}
}
query {
urls{
id
urlFull
urlHash
visits
dateCreated
__typename
}
}
docker compose up -d --build
- if fails
docker compose down -v
docker compose exec web python manage.py migrate --noinput
docker compose exec web python manage.py migrate
docker compose exec db psql --username=postgres --dbname=postgres_dev
docker volume inspect tifyone_postgres_data
chmod +x entrypoint.sh
-
docker compose -f docker-compose.prod.yaml up -d --build
-
docker compose -f docker-compose.prod.yaml down -v
-
docker compose -f docker-compose.prod.yaml up -d --build
-
docker compose -f docker-compose.prod.yaml exec web python manage.py migrate --noinput
-
docker compose logs -f
-
docker compose exec web python manage.py flush --no-input
-
docker compose exec web python manage.py migrate
-
docker compose -f docker-compose.prod.yaml up -d --build
-
docker compose -f docker-compose.prod.yaml exec web python manage.py migrate --noinput
-
docker compose -f docker-compose.prod.yaml down -v
-
docker compose -f docker-compose.prod.yaml up -d --build
-
docker compose -f docker-compose.prod.yaml exec web python manage.py migrate --noinput
manage.py migrate manage.py collectstatic --no-input
upstream web_server {
# docker will automatically resolve this to the correct address
# because we use the same name as the service: "web"
server web:8000;
}
# declare main server NGINX
server {
listen 80;
server_name localhost;
location / {
# everything is passed to Gunicorn
proxy_pass http://web_server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location /static/ {
alias /usr/src/code/static/;
}
location /media/ {
alias /usr/src/code/media/;
}
}
- Kubernetes cluster
- kubectl
- domain name
- ingres-nginx
- DNS record A
- storage object
- Django app
- Postgres database
- Docker hub
- Docker engine
- create ssh key pair
- `ssh-keygen -t rsa -b 4096"