Skip to content

Commit

Permalink
Overhaul: add Dev Containers, move doc_src to docs, migrate link to h…
Browse files Browse the repository at this point in the history
…ttps:, lint markdown
  • Loading branch information
john-cd committed Mar 7, 2024
1 parent b940cce commit 7a30cf5
Show file tree
Hide file tree
Showing 226 changed files with 2,435 additions and 172,178 deletions.
90 changes: 90 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# syntax=docker/dockerfile:1

# Dockerfile reference guide at
# https://docs.docker.com/go/dockerfile-reference/

ARG WORK_DIR="/code"

ARG PYTHON_VERSION=3.12
FROM python:${PYTHON_VERSION}-slim as base

# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1

# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1

RUN pip install mkdocs
RUN pip install mkdocs-material
## https://github.com/byrnereese/mkdocs-minify-plugin
#RUN pip install mkdocs-minify-plugin
## https://github.com/mkdocs/mkdocs-redirects
#RUN pip install mkdocs-redirects

ARG WORK_DIR
WORKDIR $WORK_DIR


## -------------------------------------------------------------
FROM base AS dev

# Install additional OS packages.
# Install pix
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends git pipx

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create a non-privileged user
# See https://docs.docker.com/go/dockerfile-user-best-practices/
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
# Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# Switch to the non-privileged user.
USER $USERNAME

# Create aliases
RUN <<EOF
set -ex
echo 'alias ll="ls -alF"' >> $HOME/.bashrc
echo 'alias la="ls -A"' >> $HOME/.bashrc
echo 'alias l="ls -CF"' >> $HOME/.bashrc
EOF

# # Install Poetry
# # Change some Poetry settings to better deal with working in a container
# ARG WORK_DIR
# RUN --mount=type=cache,target=${WORK_DIR}/.cache \
# pipx install poetry \
# && pipx ensurepath

# Expose the port that the application listens on.
#EXPOSE 8000

CMD while sleep 1000; do :; done

## Run if necessary:
# poetry self update \
# && poetry config cache-dir "${WORK_DIR}/.cache" \
# && poetry config virtualenvs.in-project true \
# && poetry completions bash >> ~/.bash_completion \
# && poetry install

## -------------------------------------------------------------
FROM base AS ci

# Copy the source code into the container.
COPY . .

ARG WORK_DIR
RUN rm -rf $WORK_DIR/site/ && mkdocs build

#CMD [ "ci.sh" ]
8 changes: 8 additions & 0 deletions .devcontainer/compose-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: cheatsheets_ci
services:
site:
build:
target: ci
# Bind the output folder to a folder in the CI host
volumes:
- ../site:/code/site
14 changes: 14 additions & 0 deletions .devcontainer/compose.override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: cheatsheets_dev
services:
site:
build:
target: dev
ports:
- 8000:8000
volumes:
# Update this to wherever you want VS Code to mount the folder of your project
- ..:/code:cached
- /var/run/docker.sock:/var/run/docker-host.sock

# Overrides default command so things don't shut down after the process ends.
#command: /bin/sh -c "while sleep 1000; do :; done"
14 changes: 14 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.8'

# Docker Compose reference guide at
# https://docs.docker.com/go/compose-spec-reference/
#For examples, see the Awesome Compose repository:
# https://github.com/docker/awesome-compose
# Note that the path of the Dockerfile and context is relative to the *primary*
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
# array).
services:
site:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
60 changes: 60 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "Docker Compose",

// 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": [
"compose.yaml",
"compose.override.yaml"
],

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/compose.yaml to the real service name.
"service": "site",

// 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": "/code", // "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"moby": true,
"installDockerBuildx": true,
"version": "latest",
"dockerDashComposeVersion": "v2"
}
},

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

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
// "customizations": {},
"customizations": {
"vscode": {
"extensions": [
// "ms-python.vscode-pylance",
// "ms-python.python",
// "ms-python.debugpy",
"DavidAnson.vscode-markdownlint",
"redhat.vscode-yaml"
]
}
}

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
35 changes: 35 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

site/
**/.DS_Store
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
144 changes: 128 additions & 16 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,17 +1,129 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
* text=auto eol=lf

## -----------------------------------------------------

# Basic .gitattributes for a python repo.

# Source files
# ============
*.pxd text diff=python
*.py text diff=python
*.py3 text diff=python
*.pyw text diff=python
*.pyx text diff=python
*.pyz text diff=python
*.pyi text diff=python

# Binary files
# ============
*.db binary
*.p binary
*.pkl binary
*.pickle binary
*.pyc binary export-ignore
*.pyo binary export-ignore
*.pyd binary

# Jupyter notebook
*.ipynb text eol=lf

# Note: .db, .p, and .pkl files are associated
# with the python modules ``pickle``, ``dbm.*``,
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
# (among others).

## -----------------------------------------------------

# Fix syntax highlighting on GitHub to allow comments
.devcontainer.json linguist-language=JSON-with-Comments
devcontainer.json linguist-language=JSON-with-Comments

## -----------------------------------------------------

# Fix syntax highlighting on GitHub to allow comments
.vscode/*.json linguist-language=JSON-with-Comments

## -----------------------------------------------------

# Common settings that generally should always be used with your language specific settings

#
# The above will handle all files NOT found below
#

# Documents
*.bibtex text diff=bibtex
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.md text diff=markdown
*.mdx text diff=markdown
*.tex text diff=tex
*.adoc text
*.textile text
*.mustache text
*.csv text eol=crlf
*.tab text
*.tsv text
*.txt text
*.sql text
*.epub diff=astextplain

# Graphics
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.tif binary
*.tiff binary
*.ico binary
# SVG treated as text by default.
*.svg text
# If you want to treat it as binary,
# use the following line instead.
# *.svg binary
*.eps binary

# Scripts
*.bash text eol=lf
*.fish text eol=lf
*.ksh text eol=lf
*.sh text eol=lf
*.zsh text eol=lf
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf

# Serialisation
*.json text
*.toml text
*.xml text
*.yaml text
*.yml text

# Archives
*.7z binary
*.gz binary
*.tar binary
*.tgz binary
*.zip binary

# Text files where line endings should be preserved
*.patch -text

#
# Exclude files from exporting
#

.gitattributes export-ignore
.gitignore export-ignore
.gitkeep export-ignore
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: monthly
Loading

0 comments on commit 7a30cf5

Please sign in to comment.