Skip to content

Commit 3be0cf4

Browse files
Simply compose dependencies and update docs.
1 parent 499506e commit 3be0cf4

File tree

7 files changed

+68
-27
lines changed

7 files changed

+68
-27
lines changed

.github/workflows/development.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ jobs:
4242
IMAGE: ${{matrix.image}}
4343
DOCKER_CLIENT_TIMEOUT: "120"
4444
COMPOSE_HTTP_TIMEOUT: "120"
45-
AS_SCRIPT: "TRUE"
4645
steps:
4746
- uses: actions/checkout@v2
4847
- name: Compile image

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
44

55
## [Unreleased]
66
### Added
7-
- Add docker `dev` environment that supports hot reloading.
7+
- Docker `dev` environment that supports hot reloading.
8+
- Documentation on setting up environments within `docker-compose` header.
89

910
## [0.1.0a5] - 2021-02-18
1011
### Added

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@ Usage and API documentation currently available within method docstrings. See Py
2020

2121
## Run Locally w/ Docker
2222

23-
- Copy a `*-docker-compose.yaml` file corresponding to your usage to `docker-compose.yaml`. This file is untracked so feel free to modify as necessary.
24-
- Check the first comment which will provide best instruction on how to start the service.
23+
- Copy a `*-docker-compose.yaml` file corresponding to your usage to `docker-compose.yaml`. This file is untracked so feel free to modify as necessary. Idea is to commit anything generic but system/setup dependent should go on 'your' version i.e. local UID/GID, etc.
24+
- Check the first comment which will provide the best instruction on how to start the service; yes, it is a bit long. Note: Any of the keyword arguments prepended to the `docker-compose` command can be safely moved into a dedicated `.env` and read automatically if they are not evaluated i.e. `$(...)`. Below is a brief description of the non-evaluated environment variables:
25+
26+
```shell
27+
PY_VER=3.8 # Python version: 3.6|3.7|3.8
28+
IMAGE=djtest # Image type: djbase|djtest|djlab|djlabhub
29+
DISTRO=alpine # Distribution: alpine|debian
30+
AS_SCRIPT= # If 'TRUE', will not keep container alive but run tests and exit
31+
```
2532

2633
> ⚠️ Deployment options currently being considered are [Docker Compose](https://docs.docker.com/compose/install/) and [Kubernetes](https://kubernetes.io/docs/tutorials/kubernetes-basics/).
2734
@@ -31,17 +38,6 @@ Usage and API documentation currently available within method docstrings. See Py
3138
- For development, use CLI command `pharus`. This method supports hot-reloading so probably best coupled with `pip install -e ...`.
3239
- For production, use `gunicorn --bind 0.0.0.0:${PHARUS_PORT} pharus.server:app`.
3340

34-
## Run Tests for Development w/ Docker
35-
36-
- Create a `.env` as appropriate for your setup:
37-
```shell
38-
PY_VER=3.8 # Python version: 3.6|3.7|3.8
39-
IMAGE=djtest # Image type: djbase|djtest|djlab|djlabhub
40-
DISTRO=alpine # Distribution: alpine|debian
41-
AS_SCRIPT= # If 'TRUE', will not keep container alive but run tests and exit
42-
```
43-
- Navigate to `test-docker-compose.yaml` and check first comment which will provide best instruction on how to start the service. Yes, the command is a bit long...
44-
4541
## Run Tests for Development w/ Pytest and Flake8
4642

4743
- Set `pharus` testing environment variables:

docker-compose-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-build.yaml up --exit-code-from pharus --build
1+
# PY_VER=3.8 IMAGE=djbase DISTRO=alpine PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-build.yaml up --exit-code-from pharus --build
22
#
33
# Intended for updating dependencies and docker image.
44
# Used to build release artifacts.

docker-compose-deploy.yaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
1-
# docker-compose -f docker-compose-deploy.yaml pull
2-
# docker-compose -f docker-compose-deploy.yaml up -d
1+
# PHARUS_VERSION=0.1.0a5 docker-compose -f docker-compose-deploy.yaml pull
2+
# PHARUS_VERSION=0.1.0a5 docker-compose -f docker-compose-deploy.yaml up -d
33
#
44
# Intended for production deployment.
5-
# Note: You must run both commands above
5+
# Note: You must run both commands above for minimal outage
6+
# Make sure to add an entry into your /etc/hosts file as `127.0.0.1 fakeservices.datajoint.io`
7+
# This serves to as an alias for the domain to resolve locally.
8+
# With this config and the configuration below in NGINX, you should be able to verify it is
9+
# running properly with a `curl https://fakeservices.datajoint.io/api/version`
610
version: "2.4"
11+
x-net: &net
12+
networks:
13+
- main
714
services:
815
pharus:
9-
image: datajoint/pharus:latest
16+
<<: *net
17+
image: datajoint/pharus:${PHARUS_VERSION}
1018
# environment: # configurable values with defaults
1119
# - PHARUS_PORT=5000
1220
# - PHARUS_PREFIX=/
21+
fakeservices.datajoint.io:
22+
<<: *net
23+
image: raphaelguzman/nginx:v0.0.15
24+
environment:
25+
- ADD_pharus_TYPE=REST
26+
- ADD_pharus_ENDPOINT=pharus:5000
27+
- ADD_pharus_PREFIX=/api
28+
- HTTPS_PASSTHRU=TRUE
1329
ports:
14-
- "5000:5000"
30+
- "443:443"
31+
- "80:80"
32+
depends_on:
33+
pharus:
34+
condition: service_healthy
35+
networks:
36+
main:

docker-compose-dev.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
# PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-dev.yaml up
1+
# PY_VER=3.8 IMAGE=djbase DISTRO=alpine PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-dev.yaml up
22
#
33
# Intended for normal development. Supports hot/live reloading.
4-
# Note: If requirements or Dockerfile change, will need to add --build flag
4+
# Note: If requirements or Dockerfile change, will need to add --build flag to docker-compose
5+
# Make sure to add an entry into your /etc/hosts file as `127.0.0.1 fakeservices.datajoint.io`
6+
# This serves to as an alias for the domain to resolve locally.
7+
# With this config and the configuration below in NGINX, you should be able to verify it is
8+
# running properly with a `curl https://fakeservices.datajoint.io/api/version`
59
version: "2.4"
10+
x-net: &net
11+
networks:
12+
- main
613
services:
714
pharus:
815
<<: *net
@@ -14,3 +21,19 @@ services:
1421
volumes:
1522
- ./pharus:/opt/conda/lib/python3.8/site-packages/pharus
1623
command: pharus
24+
fakeservices.datajoint.io:
25+
<<: *net
26+
image: raphaelguzman/nginx:v0.0.15
27+
environment:
28+
- ADD_pharus_TYPE=REST
29+
- ADD_pharus_ENDPOINT=pharus:5000
30+
- ADD_pharus_PREFIX=/api
31+
- HTTPS_PASSTHRU=TRUE
32+
ports:
33+
- "443:443"
34+
- "80:80"
35+
depends_on:
36+
pharus:
37+
condition: service_healthy
38+
networks:
39+
main:

docker-compose-test.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-test.yaml up --exit-code-from pharus
1+
# PY_VER=3.8 IMAGE=djtest DISTRO=alpine AS_SCRIPT=FALSE PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-test.yaml up --exit-code-from pharus
22
#
33
# Intended for running test suite locally.
44
# Note: If requirements or Dockerfile change, will need to add --build flag
@@ -30,8 +30,8 @@ services:
3030
- sh
3131
- -c
3232
- |
33-
if [ ! -z "$${AS_SCRIPT}" ]; then
34-
set -e
33+
set -e
34+
if echo "${AS_SCRIPT}" | grep -i true &>/dev/null; then
3535
echo "------ SYNTAX TESTS ------"
3636
PKG_DIR=/opt/conda/lib/python3.8/site-packages/pharus
3737
flake8 $${PKG_DIR} --count --select=E9,F63,F7,F82 --show-source --statistics
@@ -41,7 +41,7 @@ services:
4141
flake8 $${PKG_DIR} --count --max-complexity=20 --max-line-length=95 --statistics
4242
else
4343
echo "=== Running ==="
44-
echo "Please see 'LNX-docker-compose.yaml' for detail on running tests."
44+
echo "Please see 'docker-compose-test.yaml' for detail on running tests."
4545
tail -f /dev/null
4646
fi
4747
depends_on:

0 commit comments

Comments
 (0)