Skip to content

Commit

Permalink
Merge branch 'main' into improve-mean-eccentric-anomaly
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwweber authored Mar 12, 2024
2 parents 0452de4 + bb1d8a5 commit e259c5d
Show file tree
Hide file tree
Showing 50 changed files with 4,749 additions and 2,234 deletions.
8 changes: 4 additions & 4 deletions .devcontainer/Dockerfile.math-api
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# syntax=docker/dockerfile:1.5-labs
FROM node:18-alpine AS deps
# syntax=docker/dockerfile:1
FROM node:20-alpine AS deps

WORKDIR /usr/src/app
ADD https://github.com/bryanwweber/math-api.git .
RUN yarn install --frozen-lockfile

FROM node:18-alpine AS builder
FROM node:20-alpine AS builder
WORKDIR /usr/src/app
COPY --from=deps /usr/src/app/server.ts .
COPY --from=deps /usr/src/app/index.ts .
Expand All @@ -15,7 +15,7 @@ COPY --from=deps /usr/src/app/package.json .
COPY --from=deps /usr/src/app/node_modules ./node_modules
RUN npm run build

FROM node:18-alpine as runner
FROM node:20-alpine as runner

WORKDIR /usr/src/app
ENV NODE_ENV=production
Expand Down
86 changes: 33 additions & 53 deletions .devcontainer/Dockerfile.workspace
Original file line number Diff line number Diff line change
@@ -1,71 +1,51 @@
FROM python:3.10-alpine as pdm
FROM julia:1.10-bookworm as julia-builder

RUN mkdir -p /tmp/pdm
COPY pyproject.toml pdm.lock /tmp/pdm/
COPY Project.toml Manifest.toml /root/.julia/environments/v1.10/

WORKDIR /tmp/pdm
RUN julia -e "using Pkg; Pkg.instantiate(); Pkg.precompile();"

FROM python:3.12-slim-bookworm as python-builder

ENV PIP_ROOT_USER_ACTION=ignore

RUN --mount=type=cache,target=/root/.cache \
pip3 --disable-pip-version-check install pdm \
&& pdm export -f requirements > /tmp/pdm/requirements.txt

FROM alpine:3 as julia
ARG JULIA_VERSION=1.9.0-rc1
ARG JULIA_ARCH="x86_64"

RUN mkdir -p /tmp/julia
WORKDIR /tmp

RUN set -x && \
if [ "$JULIA_ARCH" == "aarm64" ]; then \
JULIA_ARCH="aarch64"; \
S3_ARCH="aarch64"; \
elif [ "$JULIA_ARCH" == "aarch64" ]; then \
S3_ARCH="aarch64"; \
elif [ "$JULIA_ARCH" == "x86_64" ]; then \
S3_ARCH="x64"; \
fi; \
JULIA_INSTALLER="julia-${JULIA_VERSION}-linux-${JULIA_ARCH}.tar.gz" \
&& wget --quiet "https://julialang-s3.julialang.org/bin/checksums/julia-${JULIA_VERSION}.sha256" \
&& wget --quiet "https://julialang-s3.julialang.org/bin/linux/${S3_ARCH}/${JULIA_VERSION:0:3}/${JULIA_INSTALLER}" \
&& grep ${JULIA_INSTALLER} "julia-${JULIA_VERSION}.sha256" | sha256sum -cs \
&& tar -xf "${JULIA_INSTALLER}" -C /tmp/julia --strip-components=1 \
&& rm "${JULIA_INSTALLER}"

FROM python:3.10-bullseye as workspace
python -m pip install pdm

COPY pyproject.toml pdm.lock /project/
WORKDIR /project
RUN --mount=type=cache,target=/root/.cache \
mkdir __pypackages__ \
&& pdm sync

FROM python:3.12-bookworm as workspace

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG JULIA_DIR=/opt/julia

ENV PATH="${JULIA_DIR}/bin:${PATH}" \
HOME="/home/${USERNAME}"
ENV HOME="/home/${USERNAME}" \
PYTHONPATH=/project/pkgs \
JULIA_PATH=/usr/local/julia \
JULIA_HOME=/home/${USERNAME}/.julia

# Has to be a separate instruction to get the JULIA_PATH variable
ENV PATH="${JULIA_PATH}/bin:${PATH}"

COPY .devcontainer/fix-permissions /usr/local/bin/fix-permissions
RUN chmod a+rx /usr/local/bin/fix-permissions

# Create USERNAME with name vscode user with UID=1000 and in the 'users' group
# and make sure these dirs are writable by the `users` group.
# Create USERNAME with name vscode with UID=1000 and in the 'users' group
RUN groupadd --gid ${USER_GID} ${USERNAME} \
&& useradd --uid $USER_UID --gid ${USERNAME} --shell /bin/bash --create-home ${USERNAME} \
&& mkdir -p "${JULIA_DIR}" \
&& chown "${USER_UID}:${USER_GID}" "${JULIA_DIR}" \
&& chmod g+w /etc/passwd \
&& fix-permissions "${HOME}" \
&& fix-permissions "${JULIA_DIR}"

COPY --from=pdm /tmp/pdm/requirements.txt /tmp/pip-tmp/
RUN --mount=type=cache,target=/root/.cache \
pip3 --disable-pip-version-check install -r /tmp/pip-tmp/requirements.txt \
&& rm -rf /tmp/pip-tmp
&& useradd --uid ${USER_UID} --gid ${USER_GID} --shell /bin/bash --create-home ${USERNAME}

USER ${USERNAME}
COPY --from=python-builder /project/__pypackages__/3.12/lib /project/pkgs
COPY --from=python-builder /project/__pypackages__/3.12/bin/* /bin/
COPY --from=julia-builder /usr/local/julia ${JULIA_PATH}
COPY --from=julia-builder /root/.julia ${HOME}/.julia

COPY --from=julia /tmp/julia/ "${JULIA_DIR}/"
COPY .devcontainer/packages.jl /tmp/packages.jl
RUN chown -R "${USER_UID}:${USER_GID}" "${JULIA_HOME}" \
&& fix-permissions "${JULIA_HOME}"

RUN fix-permissions "${JULIA_DIR}"
RUN julia "/tmp/packages.jl" \
&& fix-permissions "${HOME}/.julia"
USER ${USERNAME}

WORKDIR /workspaces/orbital-mechanics-notes
26 changes: 11 additions & 15 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,44 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "Orbital Mechanics Notes",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": ["docker-compose.yml"],

"dockerComposeFile": [
"docker-compose.yml"
],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "workspace",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [8080],

"forwardPorts": [
8080
],
// Uncomment the next line if you want start specific services in your Docker Compose config.
"runServices": ["http-server", "math-api"],

"runServices": [
"http-server",
"math-api"
],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
"shutdownAction": "stopCompose",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"DavidAnson.vscode-markdownlint",
"ms-python.python",
"ms-toolsai.jupyter",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker",
"tamasfe.even-better-toml",
"VisualStudioExptTeam.vscodeintellicode"
],
"settings": {
}
"settings": {}
}
},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
"containerUser": "vscode",
"remoteUser": "vscode",
"updateRemoteUserUID": true

}
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ services:
- ..:/workspaces/orbital-mechanics-notes:cached
command: /bin/sh -c "while sleep 1000; do :; done"
http-server:
image: python:3.10-alpine
image: python:3.12-alpine
ports: ["8080:8080"]
command: python3 -m http.server 8080 -d /html
volumes:
Expand Down
16 changes: 0 additions & 16 deletions .devcontainer/packages.jl

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deploy-book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: pdm-project/setup-pdm@v4
with:
cache: true
python-version: "3.11"
python-version: "3.12"
- name: Install dependencies
run: pdm sync --prod
# Build the book
Expand Down
15 changes: 13 additions & 2 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{
"globs": ["**/*.md", "!.venv"],
"globs": [
"**/*.md",
"!.venv",
"!_build",
"!_static"
],
"config": {
"MD003": false,
"MD013": false,
"MD037": false
"MD024": false,
"MD033": false,
"MD037": false,
"MD041": false,
"MD055": false,
"MD056": false
}
}
22 changes: 21 additions & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
[tools]
python = { version = "3.11", virtualenv = ".venv" }
python = { version = "3.12", virtualenv = ".venv" }
markdownlint-cli2 = "latest"
pdm = "latest"
julia = "latest"

[plugins]
pdm = "https://github.com/1oglop1/asdf-pdm"
markdownlint-cli2 = "https://github.com/paulo-ferraz-oliveira/asdf-markdownlint-cli2"
julia = "https://github.com/rkyleg/asdf-julia.git"

[tasks]
lint = { depends = [
"ruff_check_lint",
"ruff_format_lint",
"markdownlint_lint",
], description = "Run all the linter tools", env = { MISE_JOBS = "1" } }
ruff_check_lint = { description = "Run the ruff linter", run = "ruff check ." }
ruff_format_lint = { run = "ruff format --check .", description = "Run the ruff formatter in check mode" }
markdownlint_lint = { run = "markdownlint-cli2", description = "Run markdownlint" }
ruff_check_format = { run = "ruff check --fix .", description = "Run the ruff linter in fix mode" }
ruff_format_format = { run = "ruff format .", description = "Run the ruff formatter" }
markdownlint_format = { run = "markdownlint-cli2 --fix", description = "Run markdownlint in fix mode" }
format = { depends = [
"ruff_check_format",
"ruff_format_format",
"markdownlint_format",
], description = "Run all the formatting tools", env = { MISE_JOBS = "1" } }
6 changes: 6 additions & 0 deletions .mise/tasks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# mise description="Build the book"
# mise env={PYDEVD_DISABLE_FILE_VALIDATION = "1"}
# mise source=["**/*.md", "**/*.ipynb", "**/*.svg"]
# mise outputs=["_build/html/**/*.html"]
jupyter-book build -W .
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// "---([\\n\\(\\)]|[^(\\$\\$)])*---"
// ]
}
]
],
"editor.formatOnSave": true

}
4 changes: 3 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Install/Build the Book

The repo is set up to use [mise](https://mise.jdx.dev) to install required tools. Once `mise` is installed, changing into this directory should install the correct tools with the right versions.
The repo is set up to use [mise](https://mise.jdx.dev) to install required tools. Once `mise` is installed, changing into this directory should install the correct tools with the right versions. If not, run `mise install` to install everything.

After that, running `pdm install` should install the dependencies. Then `doit build_jb` will build the book.

If you want to work on the book, you may also need to install Julia dependencies. `mise` should install Julia. Running `julia --project=. -e 'using Pkg; Pkg.instantiate(); Pkg.precompile();'` should install dependencies in a local project.
Loading

0 comments on commit e259c5d

Please sign in to comment.