Skip to content

Commit

Permalink
fix: enable deployment on rdev (#299)
Browse files Browse the repository at this point in the history
* Add symlink

* Update env config

* Update health check path

* Add temporary workarounds and warnings

* Workaround missing s3 bucket

* add request logging

* Repair explorer rdev

* Remove unused config file

* Cleanup

* Clean up

* Lint

* Reorder dockerfile to take advantage of caching

* Remove unnecessary installations

* Ignore node_modules in docker image to save space

* Fix cache-from tag in Docker

* fix conflicts

* Reorder Dockerfile for caching

Co-authored-by: Trent Smith <[email protected]>
Co-authored-by: Emanuele Bezzi <[email protected]>
  • Loading branch information
3 people authored Jul 8, 2022
1 parent aa4beab commit 10fe915
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin
dist
docs
/server/eb/customize
/server/eb/customize
/client/node_modules
5 changes: 4 additions & 1 deletion .happy/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@
"log_group_prefix": "/explorer/prod"
}
},
"tasks": {}
"tasks": {
"migrate": [],
"delete": []
}
}
1 change: 1 addition & 0 deletions .happy/terraform/envs/rdev/modules
4 changes: 2 additions & 2 deletions .happy/terraform/envs/rdev/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output explorer_url {
value = module.stack.explorer_url
output frontend_url {
value = module.stack.frontend_url
description = "The URL endpoint for the website service"
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
context: .
dockerfile: hosted/Dockerfile
cache_from:
- "${DOCKER_REPO}corpora-explorer:branch-main"
- "${DOCKER_REPO}corpora-explorer:latest"
args:
- BUILDKIT_INLINE_CACHE=1
- HAPPY_COMMIT
Expand Down
23 changes: 10 additions & 13 deletions hosted/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,32 @@ ENV DEPLOYMENT_STAGE=$HAPPY_ENV

ENV DEBIAN_FRONTEND=noninteractive

ADD hosted/requirements.txt .
ADD hosted/config.yaml config.yaml

ADD server/ server/
ADD client/ client/
ADD Makefile Makefile
ADD common.mk common.mk
ADD environment.default.json environment.default.json

RUN apt-get update && \
apt-get install -y gettext moreutils build-essential libxml2-dev python3-dev python3-pip zlib1g-dev python3-requests python3-aiohttp llvm jq npm git zip curl && \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* && \
apt-get clean

RUN curl -sL https://deb.nodesource.com/setup_15.x | bash -
RUN apt-get -y install nodejs
RUN node -v

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
ADD hosted/requirements.txt .

RUN python3 -m pip install psycopg2-binary
RUN python3 -m pip install -r requirements.txt

ADD Makefile Makefile
ADD common.mk common.mk
ADD environment.default.json environment.default.json
ADD client/ client/
RUN make build-client

ADD server/ server/
RUN mkdir -p /server/common/web/templates/

WORKDIR server/eb
RUN make build-ecs
WORKDIR /

ADD hosted/config.yaml config.yaml
ENV CXG_CONFIG_FILE=/config.yaml
CMD ["gunicorn", "--worker-class", "gevent", "--bind", "0.0.0.0:5000", "server.eb.app:application", "--timeout", "60"]
CMD ["gunicorn", "--worker-class", "gevent", "--bind", "0.0.0.0:5000", "server.eb.app:application", "--timeout", "60"]
8 changes: 7 additions & 1 deletion server/app/app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import datetime
import hashlib
import json
import logging
import os
from http import HTTPStatus
from urllib.parse import urlparse

from flask import Flask, redirect, current_app, make_response, abort, render_template, Blueprint
from flask import Flask, redirect, current_app, make_response, abort, render_template, Blueprint, request
from flask_restful import Api, Resource
from server_timing import Timing as ServerTiming

Expand Down Expand Up @@ -199,3 +200,8 @@ def __init__(self, app_config):
)

self.app.app_config = app_config

@self.app.before_request
def pre_request_logging():
message = json.dumps(dict(url=request.path, method=request.method, schema=request.scheme))
self.app.logger.info(message)
1 change: 0 additions & 1 deletion server/common/utils/data_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,4 @@ def discover_s3_region_name(uri):
return region
else:
return None

return None

0 comments on commit 10fe915

Please sign in to comment.