Skip to content

Commit

Permalink
Merge branch 'develop' into bug/expose-edl-incompatibility-1018
Browse files Browse the repository at this point in the history
  • Loading branch information
frankinspace authored Jun 19, 2024
2 parents b65c9bb + f3912fd commit 868e2a7
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 52 deletions.
9 changes: 0 additions & 9 deletions .circleci/config.yml

This file was deleted.

11 changes: 4 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ jobs:
uses: docker/login-action@v3
with:
registry: ${{ vars.GITLAB_CONTAINER_REGISTRY }}
username: gitlab+deploy-token-2
username: gitlab+deploy-token-3
password: ${{ secrets.MAAP_API_NASA_CI_GH_ACTION_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
Expand All @@ -274,16 +274,12 @@ jobs:
type=pep440,pattern={{version}},value=${{ env.THE_VERSION }}
type=raw,value=${{ needs.build.outputs.deploy_env }}
- name: Build and push Docker image
if: |
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release') ||
github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: true
# Always build but only push if triggered by protected branch or manual run
push: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') || github.event_name == 'workflow_dispatch' }}
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down Expand Up @@ -341,6 +337,7 @@ jobs:
AWS_DEFAULT_REGION: us-west-2
API_IMAGE_NAME: ${{ env.GITLAB_CONTAINER_IMAGE_URI }}
API_MACHINE: ${{ secrets.API_MACHINE }}
API_MACHINE_KEYPATH: ${{ secrets.API_MACHINE_KEYPATH }}
run: |
echo "Deploy ${{ env.API_IMAGE_NAME }} to ${{ needs.build.outputs.deploy_env }}"
${GITHUB_WORKSPACE}/.github/workflows/deploy-on-runner.sh
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/deploy-on-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

set -exo pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# # Make sure to add the public key of the CI machine to the authorized keys of the api machine
ssh "${API_MACHINE}" "docker-compose -f docker-compose-maap-api.yml down"
ssh -i ${API_MACHINE_KEYPATH} "${API_MACHINE}" "docker-compose -f docker-compose-maap-api.yml down"
# Copy new file after compose down on api machine
cat "${GITHUB_WORKSPACE}"/docker/docker-compose-maap-api.yml.tmpl | envsubst >> docker-compose-maap-api.yml
scp -v docker-compose-maap-api.yml "${API_MACHINE}":~/
scp -v .maap-api.env "${API_MACHINE}":~/.maap-api.env
cat "${GITHUB_WORKSPACE}"/docker/docker-compose-maap-api.yml.tmpl | envsubst >> "${SCRIPT_DIR}/"docker-compose-maap-api.yml
scp -i ${API_MACHINE_KEYPATH} -v "${SCRIPT_DIR}/"docker-compose-maap-api.yml "${API_MACHINE}":~/
scp -i ${API_MACHINE_KEYPATH} -v "${SCRIPT_DIR}/".maap-api.env "${API_MACHINE}":~/.maap-api.env

ssh "${API_MACHINE}" "docker-compose -f docker-compose-maap-api.yml pull"
ssh "${API_MACHINE}" "docker-compose -f docker-compose-maap-api.yml up -d"
ssh -i ${API_MACHINE_KEYPATH} "${API_MACHINE}" "docker-compose -f docker-compose-maap-api.yml pull"
ssh -i ${API_MACHINE_KEYPATH} "${API_MACHINE}" "docker-compose -f docker-compose-maap-api.yml up -d"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ local
*.DS_Store
/docker/data
docker/logs/
/logs/
/logs/
/dist/
2 changes: 1 addition & 1 deletion api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def str2bool(v):
GRQ_URL = os.getenv('GRQ_URL', 'http://[GRQ_IP]:8878/api/v0.1') # new from sister
DEFAULT_QUEUE = os.getenv('DEFAULT_QUEUE', 'test-job_worker-large')
LW_QUEUE = os.getenv('LW_QUEUE', 'system-jobs-queue')
HYSDS_LW_VERSION = os.getenv('HYSDS_LW_VERSION', 'v0.0.5')
HYSDS_LW_VERSION = os.getenv('HYSDS_LW_VERSION', 'v1.2.2')
GRQ_REST_URL = os.getenv('GRQ_REST_URL', 'http://[GRQ_IP]/api/v0.1')
S3_CODE_BUCKET = os.getenv('S3_CODE_BUCKET', 's3://[S3_BUCKET_NAME]')
DPS_MACHINE_TOKEN = os.getenv('DPS_MACHINE_TOKEN', '')
Expand Down
14 changes: 11 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ WORKDIR /maap-api-nasa
COPY pyproject.toml poetry.lock ./
RUN touch README.md

RUN poetry install --without dev && rm -rf $POETRY_CACHE_DIR
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR

FROM python:3.9-slim as runtime

ENV VIRTUAL_ENV=/maap-api-nasa/.venv \
PATH="/maap-api-nasa/.venv/bin:$PATH"
PATH="/maap-api-nasa/.venv/bin:$PATH" \
PYTHONPATH="/maap-api-nasa/.venv/lib:$PYTHONPATH"

COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}

RUN apt-get update \
&& apt-get install -y --no-install-recommends git python3-psycopg2 \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*

COPY api /maap-api-nasa/api
COPY api/settings.py /maap-api-nasa/api/settings.py
COPY logging.conf /maap-api-nasa/logging.conf

WORKDIR /maap-api-nasa

RUN mkdir /logs

4 changes: 1 addition & 3 deletions docker/docker-compose-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ services:
volumes:
- ./logs:/maap-api-nasa/logs/
command: >
sh -c "flask run --host=0.0.0.0"
environment:
FLASK_APP: /maap-api-nasa/api/maapapp.py
sh -c "flask --app api.maapapp run --host=0.0.0.0"
restart: always
logging:
driver: "json-file"
Expand Down
42 changes: 21 additions & 21 deletions poetry.lock

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

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[tool.poetry]
name = "maap-api-nasa"
version = "3.2.0a1"
version = "3.2.0a3"
description = "NASA Python implementation of the MAAP API specification"
authors = ["MAAP-Project Platform <[email protected]>"]
license = "Apache 2.0"
readme = "README.md"
packages = [
{include = "api"}
]
include = [
{ path = "logging.conf", format = ["sdist", "wheel"] }
]

[tool.poetry.dependencies]
python = "^3.9.0"
Expand Down

0 comments on commit 868e2a7

Please sign in to comment.