Skip to content

Commit

Permalink
Merge pull request #207 from LCOGT/feat/skaffold
Browse files Browse the repository at this point in the history
feat: local development w/ skaffold
  • Loading branch information
jashan-lco authored Nov 4, 2024
2 parents c701bd4 + baa5c85 commit 5cbe944
Show file tree
Hide file tree
Showing 122 changed files with 8,175 additions and 20 deletions.
31 changes: 19 additions & 12 deletions .dockerignore
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
15 changes: 15 additions & 0 deletions .github/workflows/cd.yaml
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ local_settings*

# Any local datafiles
data/star*csv
data/*ogle*
data/*ogle*

.devenv
.pre-commit-config.yaml
local-kubeconfig
22 changes: 16 additions & 6 deletions Dockerfile
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"]
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand Down
Loading

0 comments on commit 5cbe944

Please sign in to comment.