diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..5218079 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,5 @@ +# Pyencrypt Examples + +This directory contains examples of how to use pyencrypt. + +* [`django`](./django): Pyencrypt Django Example \ No newline at end of file diff --git a/examples/django/README.md b/examples/django/README.md index c7de4b6..9494787 100644 --- a/examples/django/README.md +++ b/examples/django/README.md @@ -2,4 +2,25 @@ This example shows how to use `pyencrypt` with Django. -## How to use \ No newline at end of file +## How to use +```shell +docker compose up -d +``` + +## Test +* runserver: `curl http://127.0.0.1:8001/account/login/?username=admin&password=admin` +* gunicorn: `curl http://127.0.0.1:8002/account/login/?username=admin&password=admin` + +## Note +* `manage.py` shouldn't be encrypted. +* `gunicorn.py` shouldn't be encrypted. + +### Loader +* Copy `encrypted/loader*.so` to where `manage.py` is located. +* Add `import loader` at the top of `/__init__.py`. +* Don't forget to remove `encrypted` and `build` directory. + +### Docker +* For preventing to extract origin layer from image, using [`scratch`](https://docs.docker.com/build/building/base-images/#create-a-base-image) to convert image to single layer. + > [docker: extracting a layer from a image - Stack Overflow](https://stackoverflow.com/questions/40575752/docker-extracting-a-layer-from-a-image) +* Remember to specify `WORKDIR`, `ENTRYPOINT` and other in `Dockerfile` again after `scratch`. \ No newline at end of file diff --git a/examples/django/bin/start.sh b/examples/django/bin/start.sh deleted file mode 100644 index d72beb0..0000000 --- a/examples/django/bin/start.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -python manage.py migrate -python manage.py runserver 0.0.0.0:8000 diff --git a/examples/django/compose.yml b/examples/django/compose.yml index f50da04..d320889 100644 --- a/examples/django/compose.yml +++ b/examples/django/compose.yml @@ -1,11 +1,11 @@ services: - demo1: &demo1 + demo1: build: . command: python manage.py runserver 0.0.0.0:8000 ports: - 8001:8000 demo2: - <<: *demo1 + build: . command: gunicorn -c demo/gunicorn.py demo.wsgi ports: - 8002:8000