Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
lentinj committed Apr 24, 2024
2 parents d88056d + 39c7649 commit 8f80699
Show file tree
Hide file tree
Showing 475 changed files with 28,630 additions and 121,553 deletions.
8 changes: 8 additions & 0 deletions .devcontainer/dev.Dockerfile
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/devcontainers/javascript-node:18
WORKDIR /opt
# Should align with https://github.com/OneZoom/OZtree-docker/blob/main/Dockerfile
RUN git clone --recursive https://github.com/web2py/web2py.git --depth 1 --branch v2.27.1 --single-branch web2py \
&& chown -R node:node web2py
# Required to avoid build issue when running grunt
ENV NODE_OPTIONS=--openssl-legacy-provider=0
ENV PATH=${PATH}:/opt/web2py/applications/OZtree/node_modules/.bin
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
@@ -0,0 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "OZTree Dev",
"dockerComposeFile": "docker-compose.yml",
"service": "dev",
"workspaceFolder": "/opt/web2py/applications/OZtree",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/python:1": {
"version": "3.10"
}
},
"forwardPorts": [
// This is automatically forwarded if using a local container, but not on Codespaces.
8000
],
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker"
]
}
}
}
33 changes: 33 additions & 0 deletions .devcontainer/docker-compose.yml
@@ -0,0 +1,33 @@
version: '3.8'
services:
dev:
build:
context: .
dockerfile: dev.Dockerfile
volumes:
- type: bind
source: ..
target: /opt/web2py/applications/OZtree
consistency: cached
- original-repo:/opt/web2py/applications/OZtree_original:ro
# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"
network_mode: service:web
web:
build:
context: .
dockerfile: web.Dockerfile
args:
IMAGE_NAME: ${WEB_IMAGE_NAME}
volumes:
- type: bind
source: ..
target: /opt/web2py/applications/OZtree
consistency: cached
- original-repo:/opt/web2py/applications/OZtree_original
ports:
- "8080:80"
- "3307:3306"

volumes:
original-repo:
14 changes: 14 additions & 0 deletions .devcontainer/web.Dockerfile
@@ -0,0 +1,14 @@
ARG IMAGE_NAME
FROM ${IMAGE_NAME}
# Based on https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_change-the-uidgid-of-an-existing-container-user
# This changes the www-data UID to 1000 to match the default user on the host, so that when it
# chowns everything to www-data, it doesn't make it so that the host user cannot write to the files
# anymore.
RUN groupmod --gid 1000 www-data \
&& usermod --uid 1000 --gid 1000 www-data \
&& chown -R 1000:1000 /opt/web2py/applications
# Move the original source code into a shared volume, clearing out anything from past runs.
RUN if [ -d /opt/web2py/applications/OZtree_original ]; then \
rm -rf /opt/web2py/applications/OZtree_original; \
fi \
&& mv /opt/web2py/applications/OZtree /opt/web2py/applications/OZtree_original
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
/package-lock.json binary
32 changes: 32 additions & 0 deletions .github/workflows/test-client.yml
@@ -0,0 +1,32 @@
name: OZTreeModule CI

on:
push:
branches:
- main
- production
tags:
- 'v*'
pull_request:
branches:
- main
- production

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
- run: npm ci
- run: npm run build --if-present
- run: npm test
- run: ./node_modules/.bin/grunt compile-js
- run: ./node_modules/.bin/grunt compile-js_dev
- run: ./node_modules/.bin/grunt css
- run: ./node_modules/.bin/grunt compress
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -15,3 +15,5 @@ OZprivate/rawJS/OZTreeModule/dist/*
OZprivate/rawJS/OZTreeModule/docs/_compiled.markdown
node_modules
OZprivate/ServerScripts/Tests/BlatSearch.code_cache
.env
/static/uikit-3/
18 changes: 9 additions & 9 deletions Gruntfile.js
Expand Up @@ -6,6 +6,7 @@ const path = require('path');
partial_install_site = "http://www.onezoom.org";
partial_local_install_site = "http://127.0.0.1:8000"; // if you are running a local installation
preferred_python3 = "python3.10"; // in case you have multiple python3 versions installed
version_uikit = "3.18.3";
web2py_py = path.join(path.dirname(path.dirname(process.cwd())), 'web2py.py');
venv_python = path.join(path.dirname(path.dirname(process.cwd())), 'bin/python');

Expand Down Expand Up @@ -48,10 +49,9 @@ module.exports = function (grunt) {
].join(" && "),
},
web2py_start_dev: {
cwd: "../../",
cwd: "./",
command: [
'( [ -f oz.crt ] || openssl req -newkey rsa:2048 -x509 -days 365 -nodes -keyout oz.key -subj "/CN=dev.onezoom/" -out oz.crt; )',
venv_python + ' web2py.py -c oz.crt -k oz.key -p 8000 -a pass',
'./web2py-run',
].join(" && "),
},
compile_python: {
Expand Down Expand Up @@ -102,18 +102,18 @@ module.exports = function (grunt) {
},
compile_js: {
command: [
// Only pass --openssl-legacy-provider if node recognises it (NB: FreeBSD node18 doesn't)
'export NODE_OPTIONS="$(node --help | grep -o -- --openssl-legacy-provider || true)"',
'npm run compile_js',
].join(" && "),
},
compile_js_dev: {
command: [
// Only pass --openssl-legacy-provider if node recognises it (NB: FreeBSD node18 doesn't)
'export NODE_OPTIONS="$(node --help | grep -o -- --openssl-legacy-provider || true)"',
'npm run compile_js_dev',
].join(" && "),
},
fetch_uikit: {
cwd: "static/uikit-3/",
command: '[ -f "uikit-'+version_uikit+'.zip" ] || { rm -rf -- "uikit-*.zip"; curl -LO "https://github.com/uikit/uikit/releases/download/v'+version_uikit+'/uikit-'+version_uikit+'.zip" && unzip -o "uikit-'+version_uikit+'.zip" || rm -- "uikit-'+version_uikit+'.zip"; }',
},
unify_docs: {
//put all markdown files referred to in OZTreeModule/docs/index.markdown in a single _compiled.markdown file
//and substitute .png / svg images with data (base64 encoded for png) so they become embedded in the doc
Expand Down Expand Up @@ -250,7 +250,7 @@ module.exports = function (grunt) {
grunt.registerTask("partial-install", ["compile-js", "css", "copy:dev", "curl-dir:get_minlife", "exec:convert_links_to_local"]);
grunt.registerTask("partial-local-install", ["compile-js", "css", "copy:dev", "curl-dir:get_local_minlife", "exec:convert_links_to_local"]);
grunt.registerTask("web2py", ["exec:web2py_configure"]);
grunt.registerTask("prod", ["clean", "web2py", "compile-python", "compile-js", "css", "compress", "copy:prod", "make_release_info", "docs"]);
grunt.registerTask("dev", ["clean", "web2py", "compile-js_dev", "css", "compress", "copy:dev", "make_release_info", "docs"]);
grunt.registerTask("prod", ["clean", "web2py", "exec:fetch_uikit", "compile-python", "compile-js", "css", "compress", "copy:prod", "make_release_info", "docs"]);
grunt.registerTask("dev", ["clean", "web2py", "exec:fetch_uikit", "compile-js_dev", "css", "compress", "copy:dev", "make_release_info", "docs"]);
grunt.registerTask("start-dev", ['exec:web2py_start_dev']);
};

0 comments on commit 8f80699

Please sign in to comment.