Skip to content

Commit

Permalink
docs: ✏️ django example README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoQi99 committed Dec 3, 2024
1 parent a74a9dc commit 0c4f053
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
5 changes: 5 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Pyencrypt Examples

This directory contains examples of how to use pyencrypt.

* [`django`](./django): Pyencrypt Django Example
23 changes: 22 additions & 1 deletion examples/django/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,25 @@

This example shows how to use `pyencrypt` with Django.

## How to use
## 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 `<project>/__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`.
4 changes: 0 additions & 4 deletions examples/django/bin/start.sh

This file was deleted.

4 changes: 2 additions & 2 deletions examples/django/compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0c4f053

Please sign in to comment.