-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from LCOGT/feat/skaffold
feat: local development w/ skaffold
- Loading branch information
Showing
122 changed files
with
8,175 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
.git | ||
*.pyc | ||
*.pyo | ||
__pycache__ | ||
env/ | ||
.idea | ||
*~ | ||
README.md | ||
LICENSE | ||
Jenkinsfile | ||
docker-compose.yml | ||
helm-chart | ||
# first ignore everything | ||
**/* | ||
|
||
# now add things to include | ||
!./poetry-requirement.txt | ||
!./README.md | ||
!./pyproject.toml | ||
!./poetry.toml | ||
!./poetry.lock | ||
!./mop/ | ||
!./microlensing_targets/ | ||
!./manage.py | ||
!./static/ | ||
!./templates/ | ||
|
||
# but stil ignore | ||
**/*__pycache__ | ||
**/*.pyc | ||
**/*.pyo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: "Continuous Deployment" | ||
on: | ||
push: | ||
branches: | ||
- master | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
cd: | ||
uses: LCOGT/reusable-workflows/.github/workflows/continuous-deployment.yaml@main | ||
with: | ||
skaffoldBuildModules: "mop" | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
FROM python:3.10 | ||
LABEL maintainer="[email protected]" | ||
|
||
# the exposed port must match the deployment.yaml containerPort value | ||
EXPOSE 80 | ||
ENTRYPOINT [ "/usr/local/bin/gunicorn", "mop.wsgi", "-b", "0.0.0.0:80", "--access-logfile", "-", "--error-logfile", "-", "-k", "gevent", "--timeout", "300", "--workers", "2"] | ||
|
||
WORKDIR /mop | ||
|
||
COPY requirements.txt /mop | ||
RUN pip install --no-cache-dir -r /mop/requirements.txt | ||
RUN pip install poetry | ||
|
||
COPY ./pyproject.toml ./poetry.lock ./poetry.toml /mop | ||
|
||
RUN poetry install --no-root --only main | ||
|
||
COPY . /mop | ||
|
||
# Activate virtual env | ||
ENV PATH="/mop/.venv/bin:$PATH" | ||
|
||
# disable buffering so that logs are rendered to stdout asap | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# the exposed port must match the deployment.yaml containerPort value | ||
EXPOSE 80 | ||
|
||
ENTRYPOINT [ "gunicorn", "mop.wsgi", "-b", "0.0.0.0:80", "--access-logfile", "-", "--error-logfile", "-", "-k", "gevent", "--timeout", "300", "--workers", "2"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,56 @@ | |
TOM Toolkit for the LCO microlensing team. We harvest, fit, rank and observe all events in the sky! | ||
To join the team, please contact [email protected] and/or [email protected]. | ||
|
||
## Development (w/ Kuberentes) | ||
|
||
Install [Nix](https://github.com/LCOGT/public-wiki/wiki/Install-Nix) and then | ||
enter the development environment: | ||
|
||
```shell | ||
nix develop --impure | ||
``` | ||
|
||
Start a local development K8s cluster and container registry: | ||
|
||
```shell | ||
ctlptl apply -f ./local-registry.yaml -f ./local-cluster.yaml | ||
``` | ||
|
||
Spin up dependencies: | ||
|
||
```shell | ||
skaffold -m mop-deps run | ||
``` | ||
|
||
Start development loop: | ||
|
||
```shell | ||
skaffold -m mop dev | ||
``` | ||
|
||
This will watch source-code files for any changes and re-deploy automatically | ||
when they are modified. | ||
|
||
The application will be port-forwarded to a port listed in the logs: | ||
|
||
``` | ||
... | ||
Deployments stabilized in 13.077 seconds | ||
Port forwarding Service/server in namespace mop, remote port http -> http://127.0.0.1:4503 | ||
Listing files to watch... | ||
- mop | ||
Press Ctrl+C to exit | ||
... | ||
``` | ||
|
||
### Clean-up | ||
|
||
You can simply delete the application specific development cluster to clean everything up: | ||
|
||
```shell | ||
ctlptl delete -f ./local-cluster.yaml | ||
``` | ||
|
||
## Build | ||
|
||
This project is built automatically by the [LCO Jenkins Server](http://jenkins.lco.gtn/). | ||
|
Oops, something went wrong.