Skip to content

Commit

Permalink
create project iatlas-api based on iatlas-data
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter committed Mar 11, 2024
1 parent 6aff968 commit 90d3a13
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/iatlas/api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/*.md
.gitignore
.git/
Dockerfile
no_commit/
scripts/
Empty file added apps/iatlas/api/.env.example
Empty file.
26 changes: 26 additions & 0 deletions apps/iatlas/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# git
# used by git-log to rewrite usernames
.mailmap
git-genui.config.json

# produced vignettes
vignettes/*.html
vignettes/*.pdf

# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth

# Generated files
.DS_Store

# Visual Studio Code
.vscode
*.code-workspace

# VIM
*.swp
*.swo

docker/
no_commit/
scripts/__pycache__
1 change: 1 addition & 0 deletions apps/iatlas/api/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10.13
25 changes: 25 additions & 0 deletions apps/iatlas/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.10.13

# RUN apt-get -y update && apt-get -y install \
# wget && \
# # Install the GPG key for the Postgres repo
# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
# # Add the repo
# echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list && \
# apt-get -y update && \
# # Install the Postgres 12 client
# apt-get -y install postgresql-client-12

# COPY requirements.txt requirements.txt
COPY src/ /src

# RUN pip3 install -r requirements.txt

WORKDIR /
COPY docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]

# Set up the iAtlas database
# CMD python /src/build_database.py
9 changes: 9 additions & 0 deletions apps/iatlas/api/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e

if [ "$1" = 'python' ]; then
cd ${APP_DIR}
exec gosu www-data "$@"
fi

exec "$@"
7 changes: 7 additions & 0 deletions apps/iatlas/api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions apps/iatlas/api/poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[virtualenvs]
in-project = true
create = true
14 changes: 14 additions & 0 deletions apps/iatlas/api/prepare-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

PYTHON_VERSION="3.10.13"

pyenv install --skip-existing $PYTHON_VERSION

# Initializing pyenv again solves an issue encountered by GitHub action where the version of Python
# installed above is not detected.
eval "$(pyenv init -)"

pyenv local $PYTHON_VERSION
poetry env use $PYTHON_VERSION
poetry install
# poetry install --with prod,dev
68 changes: 68 additions & 0 deletions apps/iatlas/api/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "iatlas-api",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/iatlas/api/scripts",
"projectType": "application",
"targets": {
"create-config": {
"executor": "nx:run-commands",
"options": {
"command": "cp -n .env.example .env",
"cwd": "{projectRoot}"
}
},
"prepare": {
"executor": "nx:run-commands",
"options": {
"command": "./prepare-python.sh",
"cwd": "{projectRoot}"
}
},
"serve": {
"executor": "nx:run-commands",
"options": {
"command": "docker compose up",
"cwd": "apps/iatlas/api"
},
"dependsOn": []
},
"serve-detach": {
"executor": "nx:run-commands",
"options": {
"command": "docker/iatlas/serve-detach.sh {projectName}"
}
},
"build-image": {
"executor": "@nx-tools/nx-container:build",
"options": {
"context": "apps/iatlas/api",
"metadata": {
"images": ["ghcr.io/sage-bionetworks/{projectName}"],
"tags": ["type=edge,branch=main", "type=raw,value=local", "type=sha"]
},
"push": false
}
},
"publish-image": {
"executor": "@nx-tools/nx-container:build",
"options": {
"context": "apps/iatlas/api",
"metadata": {
"images": ["ghcr.io/sage-bionetworks/{projectName}"],
"tags": ["type=edge,branch=main", "type=sha"]
},
"push": true
},
"dependsOn": ["build-image"]
},
"scan-image": {
"executor": "nx:run-commands",
"options": {
"command": "trivy image ghcr.io/sage-bionetworks/{projectName}:local --quiet",
"color": true
}
}
},
"tags": ["type:app", "scope:backend", "language:python"],
"implicitDependencies": []
}
13 changes: 13 additions & 0 deletions apps/iatlas/api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.poetry]
name = "iatlas-api"
version = "0.1.0"
description = ""
authors = ["andrewelamb <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "3.10.13"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 90d3a13

Please sign in to comment.