Skip to content

Commit

Permalink
Merge pull request #203 from uc-cdis/chore/update_image_docker
Browse files Browse the repository at this point in the history
Update Image
  • Loading branch information
Avantol13 authored Feb 24, 2025
2 parents ba2c428 + b3c8a71 commit e745263
Show file tree
Hide file tree
Showing 31 changed files with 3,359 additions and 2,867 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ exclude_also =
if __name__ == .__main__.:

; Don't complain about abstract methods, they aren't run:
@(abc\.)?abstractmethod
@(abc\.)?abstractmethod
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
**/*.pyc
**/*.egg-info
**/__pycache__
knowledge/
prof/
tests/
tsvs/
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
repos:
- repo: [email protected]:Yelp/detect-secrets
rev: v1.4.0
rev: v1.5.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
exclude: poetry.lock
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: no-commit-to-branch
args: [--branch, develop, --branch, master, --pattern, release/.*]
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 25.1.0
hooks:
- id: black
159 changes: 159 additions & 0 deletions .secrets.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"version": "1.5.0",
"plugins_used": [
{
"name": "ArtifactoryDetector"
},
{
"name": "AWSKeyDetector"
},
{
"name": "AzureStorageKeyDetector"
},
{
"name": "Base64HighEntropyString",
"limit": 4.5
},
{
"name": "BasicAuthDetector"
},
{
"name": "CloudantDetector"
},
{
"name": "DiscordBotTokenDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"name": "GitLabTokenDetector"
},
{
"name": "HexHighEntropyString",
"limit": 3.0
},
{
"name": "IbmCloudIamDetector"
},
{
"name": "IbmCosHmacDetector"
},
{
"name": "IPPublicDetector"
},
{
"name": "JwtTokenDetector"
},
{
"name": "KeywordDetector",
"keyword_exclude": ""
},
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "OpenAIDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "PypiTokenDetector"
},
{
"name": "SendGridDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
{
"name": "TelegramBotTokenDetector"
},
{
"name": "TwilioKeyDetector"
}
],
"filters_used": [
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
},
{
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
},
{
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
},
{
"path": "detect_secrets.filters.heuristic.is_lock_file"
},
{
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
},
{
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
},
{
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
},
{
"path": "detect_secrets.filters.heuristic.is_sequential_string"
},
{
"path": "detect_secrets.filters.heuristic.is_swagger_file"
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
}
],
"results": {
".github/workflows/ci.yml": [
{
"type": "Secret Keyword",
"filename": ".github/workflows/ci.yml",
"hashed_secret": "3e26d6750975d678acb8fa35a0f69237881576b0",
"is_verified": false,
"line_number": 17
}
],
"tests/.env": [
{
"type": "Secret Keyword",
"filename": "tests/.env",
"hashed_secret": "6ffd8b80f2a76ca670ae33ab196f7936d59fb43b",
"is_verified": false,
"line_number": 8
}
],
"tests/tsvs/bdc/bdc_2.tsv": [
{
"type": "Hex High Entropy String",
"filename": "tests/tsvs/bdc/bdc_2.tsv",
"hashed_secret": "b6bb1128fca99567fb54d64d76630a9223f4c394",
"is_verified": false,
"line_number": 2
}
]
},
"generated_at": "2025-01-17T16:26:37Z"
}
57 changes: 23 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1,45 @@
FROM quay.io/cdis/amazonlinux:python3.9-master as build-deps
ARG AZLINUX_BASE_VERSION=master

USER root
# Base stage with python-build-base
FROM quay.io/cdis/python-nginx-al:${AZLINUX_BASE_VERSION} AS base

ENV appname=gen3discoveryai

RUN pip3 install --no-cache-dir --upgrade poetry
WORKDIR /$appname

RUN yum update -y && yum install -y --setopt install_weak_deps=0 \
kernel-devel libffi-devel libxml2-devel libxslt-devel postgresql-devel python3-devel \
git && yum clean all
RUN chown -R gen3:gen3 /${appname}

WORKDIR /$appname
# Builder stage
FROM base AS builder

# RUN yum update -y && yum install -y --setopt install_weak_deps=0 \
# kernel-devel libffi-devel libxml2-devel libxslt-devel postgresql-devel python3-devel \
# git && yum clean all

USER gen3

# copy ONLY poetry artifact, install the dependencies but not gen3discoveryai
# this will make sure that the dependencies are cached
COPY poetry.lock pyproject.toml /$appname/
COPY ./docs/openapi.yaml /$appname/docs/openapi.yaml
RUN poetry config virtualenvs.in-project true \
&& poetry install -vv --no-root --only main --no-interaction \
&& poetry show -v

# copy source code ONLY after installing dependencies
COPY . /$appname
RUN poetry install -vv --without dev --no-interaction

# install gen3discoveryai
RUN poetry config virtualenvs.in-project true \
&& poetry install -vv --only main --no-interaction \
&& poetry show -v
# copy source code and needed files ONLY after installing dependencies
COPY --chown=gen3:gen3 . /$appname

#Creating the runtime image
FROM quay.io/cdis/amazonlinux:python3.9-master
# Run poetry again so this app itself gets installed too
RUN poetry install --without dev --no-interaction

ENV appname=gen3discoveryai
# Creating the runtime image
FROM base

USER root
USER gen3

COPY --from=builder /${appname} /${appname}
WORKDIR /${appname}
EXPOSE 80

RUN pip3 install --no-cache-dir --upgrade poetry

RUN yum update -y && yum install -y --setopt install_weak_deps=0 \
postgresql-devel shadow-utils\
bash && yum clean all

RUN useradd -ms /bin/bash appuser

COPY --from=build-deps --chown=appuser:appuser /$appname /$appname

WORKDIR /$appname

USER appuser

# Cache the necessary tiktoken encoding file
RUN poetry run python -c "from langchain.text_splitter import TokenTextSplitter; TokenTextSplitter.from_tiktoken_encoder(chunk_size=100, chunk_overlap=0)"

Expand Down
Loading

0 comments on commit e745263

Please sign in to comment.