Skip to content

Commit

Permalink
fix: updates for 7.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
philtweir committed Jun 8, 2024
1 parent 6d6d182 commit 9eb116a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN echo "{}" > ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/webpack/webpack-
WORKDIR ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}
RUN mkdir -p /static_root && chown -R arches /static_root
WORKDIR ${WEB_ROOT}/${ARCHES_PROJECT}
RUN ../entrypoint.sh install_yarn_components
RUN ../entrypoint.sh install_npm_components
ENTRYPOINT ../entrypoint.sh
CMD run_arches
USER 1000
8 changes: 4 additions & 4 deletions Dockerfile.static
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ ENV DJANGO_DEBUG=False \
DJANGO_SETTINGS_MODULE=${ARCHES_PROJECT}.settings
WORKDIR ${WEB_ROOT}/${ARCHES_PROJECT}

RUN ${WEB_ROOT}/entrypoint.sh init_yarn_components
RUN ${WEB_ROOT}/entrypoint.sh init_npm_components

# FIXME: To be replaced once per-project settings working
RUN (echo "\nSTATIC_ROOT='${STATIC_ROOT}'" >> ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/settings_local.py) && echo $STATIC_ROOT
RUN (echo "\nARCHES_NAMESPACE_FOR_DATA_EXPORT='${ARCHES_NAMESPACE_FOR_DATA_EXPORT}'" >> ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/settings_local.py) && echo $STATIC_ROOT
RUN (echo "\nPUBLIC_SERVER_ADDRESS='${PUBLIC_SERVER_ADDRESS}' or ARCHES_NAMESPACE_FOR_DATA_EXPORT" >> ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/settings_local.py) && echo $STATIC_ROOT

RUN (cd $WEB_ROOT/arches/arches && NODE_OPTIONS=--max_old_space_size=8192 NODE_PATH=$WEB_ROOT/$ARCHES_PROJECT/$ARCHES_PROJECT/media/node_modules yarn install)
RUN (cd $WEB_ROOT/$ARCHES_PROJECT/$ARCHES_PROJECT && NODE_OPTIONS=--max_old_space_size=8192 NODE_PATH=./media/node_modules yarn install -D)
RUN (cd $WEB_ROOT/arches/arches && NODE_OPTIONS=--max_old_space_size=8192 NODE_PATH=$WEB_ROOT/$ARCHES_PROJECT/$ARCHES_PROJECT/media/node_modules npm install)
RUN (cd $WEB_ROOT/$ARCHES_PROJECT/$ARCHES_PROJECT && NODE_OPTIONS=--max_old_space_size=8192 NODE_PATH=./media/node_modules npm install -D)
RUN apt-get update && apt-get -y install python3-libxml2 git
RUN /bin/bash -c ". ../ENV/bin/activate;\
python manage.py createcachetable;\
Expand All @@ -69,7 +69,7 @@ python manage.py es index_database\
";
COPY ./${ARCHES_PROJECT}/settings.py ${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}/settings.py
RUN echo $WEB_ROOT "|" $ARCHES_PROJECT && ${WEB_ROOT}/entrypoint.sh run_arches
RUN echo $WEB_ROOT "|" $ARCHES_PROJECT && ${WEB_ROOT}/entrypoint.sh run_yarn_build_${ARCHES_ENVIRONMENT}
RUN echo $WEB_ROOT "|" $ARCHES_PROJECT && ${WEB_ROOT}/entrypoint.sh run_npm_build_${ARCHES_ENVIRONMENT}

FROM nginxinc/nginx-unprivileged:1.21.5-alpine
ARG WEB_ROOT=/web_root
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TOOLKIT_REPO = https://github.com/flaxandteal/arches-container-toolkit
TOOLKIT_FOLDER = docker
TOOLKIT_RELEASE = main
ARCHES_PROJECT ?= $(shell ls -1 */__init__.py | head -n 1 | sed 's/\/.*//g')
ARCHES_BASE = ghcr.io/flaxandteal/arches-base-7.5-dev:coral
ARCHES_BASE = ghcr.io/flaxandteal/arches-base:coral
ARCHES_PROJECT_ROOT = $(shell pwd)/
DOCKER_COMPOSE_COMMAND = ARCHES_PROJECT_ROOT=$(ARCHES_PROJECT_ROOT) ARCHES_BASE=$(ARCHES_BASE) ARCHES_PROJECT=$(ARCHES_PROJECT) docker-compose -p $(ARCHES_PROJECT) -f docker/docker-compose.yml
CMD ?=
Expand Down Expand Up @@ -67,11 +67,11 @@ build: docker
# We need to have certain node modules, so if the additional ones are missing, clean the folder to ensure boostrap does so.
if [ -z $(ARCHES_PROJECT)/media/node_modules/jquery-validation ]; then rm -rf $(ARCHES_PROJECT)/media/node_modules; fi
$(DOCKER_COMPOSE_COMMAND) stop
$(DOCKER_COMPOSE_COMMAND) run --entrypoint /web_root/entrypoint.sh arches_worker install_yarn_components
$(DOCKER_COMPOSE_COMMAND) run --entrypoint /web_root/entrypoint.sh arches_worker install_npm_components
$(DOCKER_COMPOSE_COMMAND) run --entrypoint /web_root/entrypoint.sh arches_worker bootstrap

if [ -d $(ARCHES_PROJECT)/pkg ]; then $(TOOLKIT_FOLDER)/act.py . load_package --yes; fi
$(DOCKER_COMPOSE_COMMAND) run --entrypoint /web_root/entrypoint.sh arches_worker run_yarn_build_development
$(DOCKER_COMPOSE_COMMAND) run --entrypoint /web_root/entrypoint.sh arches_worker run_npm_build_development
$(DOCKER_COMPOSE_COMMAND) stop
@echo "IF THIS IS YOUR FIRST TIME RUNNING make build AND YOU HAVE NOT ALREADY, MAKE SURE TO UPDATE urls.py (see make help)"

Expand All @@ -96,9 +96,9 @@ web: docker
$(DOCKER_COMPOSE_COMMAND) stop arches
$(DOCKER_COMPOSE_COMMAND) run --service-ports arches

.PHONY: yarn-development
yarn-development: docker
$(DOCKER_COMPOSE_COMMAND) run --entrypoint /web_root/entrypoint.sh arches_worker run_yarn_build_development
.PHONY: npm-development
npm-development: docker
$(DOCKER_COMPOSE_COMMAND) run --entrypoint /web_root/entrypoint.sh arches_worker run_npm_build_development

.PHONY: docker-compose
docker-compose: docker
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You probably want [the standard tooling](https://arches.readthedocs.io/en/stable
### I have no existing Arches project, but can use `arches-project` command

Install the `arches-project` tool as per the [Arches documentation](https://arches.readthedocs.io/en/stable/).
Note that it requires `yarn` as a dependency. Run:
Note that it requires `npm` as a dependency. Run:

```
arches-project create MYPROJECTNAME
Expand Down
72 changes: 35 additions & 37 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@ if [[ -z ${ARCHES_PROJECT} ]]; then
PACKAGE_JSON_FOLDER=${ARCHES_ROOT}/arches/install
else
APP_FOLDER=${WEB_ROOT}/${ARCHES_PROJECT}
# due to https://github.com/archesproject/arches/issues/4841, changes were made to yarn install
# and module deployment. Using the arches install directory for yarn.
# due to https://github.com/archesproject/arches/issues/4841, changes were made to npm install
# and module deployment. Using the arches install directory for npm.
# PTW PACKAGE_JSON_FOLDER=${ARCHES_ROOT}/arches/install
PACKAGE_JSON_FOLDER=${WEB_ROOT}/${ARCHES_PROJECT}/${ARCHES_PROJECT}
fi

# Read modules folder from yarn config file
# Read modules folder from npm config file
# Get string after '--install.modules-folder' -> get first word of the result
# -> remove line endlings -> trim quotes -> trim leading ./
YARN_MODULES_FOLDER=${PACKAGE_JSON_FOLDER}/$(awk \
-F '--install.modules-folder' '{print $2}' ${PACKAGE_JSON_FOLDER}/.yarnrc \
NPM_MODULES_FOLDER=${PACKAGE_JSON_FOLDER}/$(awk \
-F '--install.modules-folder' '{print $2}' ${PACKAGE_JSON_FOLDER} \
| awk '{print $1}' \
| tr -d $'\r' \
| tr -d '"' \
| sed -e "s/^\.\///g")

export DJANGO_PORT=${DJANGO_PORT:-8000}
#COUCHDB_URL="http://$COUCHDB_USER:$COUCHDB_PASS@$COUCHDB_HOST:$COUCHDB_PORT"
STATIC_ROOT=${STATIC_ROOT:-/static_root}

export ALLOW_BOOTSTRAP=${ALLOW_BOOTSTRAP:-}
Expand All @@ -59,7 +58,7 @@ cd_app_folder() {
echo "Current work directory: ${APP_FOLDER}"
}

cd_yarn_folder() {
cd_npm_folder() {
cd ${PACKAGE_JSON_FOLDER}
echo "Current work directory: ${PACKAGE_JSON_FOLDER}"
}
Expand All @@ -79,6 +78,7 @@ init_arches() {
echo ""
else
if [[ "${ALLOW_BOOTSTRAP}" == "True" ]]; then
echo "Database ${PGDBNAME} does not exists yet, starting setup..."
setup_arches
else
echo "Database ${PGDBNAME} does not exist yet, exiting until you 'entrypoint.sh bootstrap'..."
Expand All @@ -91,14 +91,15 @@ init_arches() {
bootstrap() {
init_arches_project

init_yarn_components
init_npm_components

setup_arches

run_yarn_build_development
run_npm_build_development

}


# Setup Postgresql and Elasticsearch
setup_arches() {
cd_arches_root
Expand All @@ -114,10 +115,6 @@ setup_arches() {
echo "Running: python manage.py setup_db --force"
python ${APP_FOLDER}/manage.py setup_db --force

#echo "Running: Creating couchdb system databases"
#curl -X PUT ${COUCHDB_URL}/_users
#curl -X PUT ${COUCHDB_URL}/_global_changes
#curl -X PUT ${COUCHDB_URL}/_replicator

if [[ "${INSTALL_DEFAULT_GRAPHS}" == "True" ]]; then
# Import graphs
Expand Down Expand Up @@ -209,23 +206,23 @@ set_dev_mode() {
}


# Yarn
init_yarn_components() {
if [[ ! -d ${YARN_MODULES_FOLDER} ]] || [[ ! "$(ls ${YARN_MODULES_FOLDER})" ]]; then
echo "Yarn modules do not exist, installing..."
install_yarn_components
# npm
init_npm_components() {
if [[ ! -d ${NPM_MODULES_FOLDER} ]] || [[ ! "$(ls ${NPM_MODULES_FOLDER})" ]]; then
echo "npm modules do not exist, installing..."
install_npm_components
fi
}

# This is also done in Dockerfile, but that does not include user's custom Arches app package.json
# Also, the packages folder may have been overlaid by a Docker volume.
install_yarn_components() {
install_npm_components() {
echo ""
echo ""
echo "----- INSTALLING YARN COMPONENTS -----"
echo "----- INSTALLING NPM COMPONENTS -----"
echo ""
cd_yarn_folder
yarn install -D
cd_npm_folder
npm install
}

#### Main commands
Expand All @@ -248,37 +245,37 @@ run_graphql_server() {
uvicorn --host 0.0.0.0 --port 8000 ${ARCHES_PROJECT}.graph.asgi:app
}

run_yarn_start() {
run_npm_start() {
echo ""
echo ""
echo "----- RUNNING YARN SERVER -----"
echo ""
cd_app_folder
sleep 10
cd ${ARCHES_PROJECT}
yarn start
npm start
}

run_yarn_build_production() {
run_npm_build_production() {
echo ""
echo ""
echo "----- RUNNING YARN SERVER -----"
echo ""
cd_app_folder
sleep 10
cd ${ARCHES_PROJECT}
yarn build_production
npm build_production
}

run_yarn_build_development() {
run_npm_build_development() {
echo ""
echo ""
echo "----- RUNNING YARN SERVER -----"
echo ""
cd_app_folder
sleep 10
cd ${ARCHES_PROJECT}
yarn build_development
npm build_development
}


Expand Down Expand Up @@ -398,7 +395,6 @@ collect_static_real(){
echo ""
cd_app_folder
python manage.py collectstatic --noinput
python manage.py compress --verbosity=3
}


Expand Down Expand Up @@ -464,6 +460,8 @@ run_arches() {

init_arches

init_npm_components

if [[ "${DJANGO_MODE}" == "DEV" ]]; then
set_dev_mode
fi
Expand Down Expand Up @@ -553,17 +551,17 @@ do
wait_for_db
run_migrations
;;
install_yarn_components)
install_yarn_components
install_npm_components)
install_npm_components
;;
run_yarn_build_development)
run_yarn_build_development
run_npm_build_development)
run_npm_build_development
;;
run_yarn_build_production)
run_yarn_build_production
run_npm_build_production)
run_npm_build_production
;;
run_yarn_start)
run_yarn_start
run_npm_start)
run_npm_start
;;
help|-h)
display_help
Expand Down

0 comments on commit 9eb116a

Please sign in to comment.