Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
60da832
Switch base image
maresb Sep 16, 2022
dece5e0
Update base image
maresb Sep 17, 2022
1859f43
Add Live Share extension
maresb Sep 17, 2022
da64c05
Update devcontainer base image
maresb Sep 17, 2022
a36c45e
Use _dev-init.sh as startup command
maresb Sep 17, 2022
6bd4544
Also run _dev-init.sh in init section
maresb Sep 17, 2022
dde2381
Update base devcontainer
maresb Sep 17, 2022
d344190
Remove Live Share since doesn't exist on OpenVSX
maresb Sep 17, 2022
6c368ae
Add Pyright extension
maresb Sep 17, 2022
ce59496
Set default interpreter path
maresb Sep 17, 2022
99da664
Install pre-commit hooks in background
maresb Sep 17, 2022
cc158bd
Also set python.pythonPath
maresb Sep 17, 2022
183cbdc
Remove deprecated python.pythonPath setting
maresb Sep 17, 2022
bc783b6
Add Git History plugin
maresb Sep 17, 2022
cff4801
Install pre-commit hooks in foreground
maresb Sep 17, 2022
e8c9e27
Add .dockerignore
maresb Sep 17, 2022
55ddc43
Add dev.Dockerfile
maresb Sep 17, 2022
fc7634a
Add workflow to build devcontainer
maresb Sep 17, 2022
adc0872
Disable arm64 devcontainer builds
maresb Sep 17, 2022
0cc5909
Sudo
maresb Sep 17, 2022
5b8bcc3
Use prebuilt PyMC devcontainer
maresb Sep 17, 2022
a9ca5ff
Make all files writeable
maresb Sep 17, 2022
57c3fef
Copy pre-built pre-commit cache if it doesn't exist yet
maresb Sep 17, 2022
11e5106
Run chmod with sudo
maresb Sep 17, 2022
5a560a0
Use updated devcontainer
maresb Sep 17, 2022
e756703
Make chmod recursive
maresb Sep 17, 2022
180857f
Update devcontainer base
maresb Sep 17, 2022
e25f841
Set PRE_COMMIT_HOME to save precomputed cache
maresb Sep 18, 2022
cab57ea
Chown conda-meta/history
maresb Sep 18, 2022
008d78c
Update devcontainer base image
maresb Sep 18, 2022
8a5a127
Remove GHA version comments
maresb Jan 26, 2023
3581165
Name image as pymc-devcontainer
maresb Jan 26, 2023
91ea267
Use latest available pymc-devcontainer
maresb Jan 26, 2023
1e2f193
Bump devcontainer base version
maresb Jan 26, 2023
c506caa
Ensure pre-commit hooks are installed
maresb Jan 26, 2023
1af8658
Add some vscode settings
maresb Jan 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
.mypy_cache
54 changes: 54 additions & 0 deletions .github/workflows/devcontainer-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: devcontainer-docker-image

on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-devcontainer # pymc-devs/pymc-devcontainer

jobs:
build-container:
runs-on: ubuntu-latest

# Set permissions for GitHub token
# <https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#authenticating-to-package-registries-on-github>
permissions:
contents: read
packages: write

steps:
- name: Checkout source
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b

- name: Setup Docker buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6

- name: Prepare metadata
id: meta
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,enable=true,prefix=git-
type=raw,value=latest

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8
with:
context: .
file: scripts/dev.Dockerfile
platforms: linux/amd64 # ,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
cache-to: type=inline
37 changes: 31 additions & 6 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
image: ghcr.io/conda/conda-ci:main-linux-python3.9
image: ghcr.io/maresb/pymc-devcontainer:latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use a pymc channel here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it needs to exist first. To create it, it should be sufficient to merge this, then run the "create devcontainer" GitHub Action (via the workflow dispatch button). Then we can change the channel here.

But this is only needed when changing the dependencies, so for the moment there is no problem to keep my channel.

tasks:
- name: initialize
init: |
# General devcontainer initialization, e.g. pre-commit
_dev-init.sh

# Create an empty object for .vscode/settings.json if the file doesn't exist
mkdir -p .vscode
echo '{"python.defaultInterpreterPath": "/workspace/pymc/env/bin/python"}' > .vscode/settings.json
conda init bash && source ~/.bashrc
conda env update -f conda-envs/environment-dev.yml -p /workspace/pymc/env
conda activate /workspace/pymc/env
[ -f .vscode/settings.json ] || echo "{}" > .vscode/settings.json

# Add vscode settings
jq '
.["python.defaultInterpreterPath"] = "/opt/conda/bin/python"
' .vscode/settings.json | sponge .vscode/settings.json
jq '
.["terminal.integrated.defaultProfile.linux"] = "bash"
' .vscode/settings.json | sponge .vscode/settings.json
jq '
.["git.autofetch"] = true
' .vscode/settings.json | sponge .vscode/settings.json

# Install dependencies
sudo chown "$(id -u):$(id -g)" /opt/conda/conda-meta/history
micromamba install --yes --name base --file conda-envs/environment-dev.yml

# Install PyMC
pip install -e .

command: |
conda init bash && echo "conda activate /workspace/pymc/env" >> ~/.bashrc && source ~/.bashrc
# Reinitialize devcontainer for good measure
_dev-init.sh

# Install the pre-commit hooks in the background if not already installed
pre-commit install --install-hooks

vscode:
extensions:
- eamodio.gitlens
- ms-python.python
- ms-pyright.pyright
- donjayamanne.githistory

github:
prebuilds:
Expand Down
21 changes: 21 additions & 0 deletions scripts/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ghcr.io/mamba-org/micromamba-devcontainer:git-5185ae9

COPY --chown=${MAMBA_USER}:${MAMBA_USER} conda-envs/environment-dev.yml /tmp/environment-dev.yml
RUN : \
&& micromamba install --yes --name base --file /tmp/environment-dev.yml \
&& micromamba clean --all --yes \
&& rm /tmp/environment-dev.yml \
&& sudo chmod -R a+rwx /opt/conda \
;

ARG MAMBA_DOCKERFILE_ACTIVATE=1

COPY --chown=${MAMBA_USER}:${MAMBA_USER} .pre-commit-config.yaml /fake-repo/.pre-commit-config.yaml
RUN : \
&& sudo mkdir --mode=777 /opt/.pre-commit-cache-prebuilt \
&& cd /fake-repo \
&& git init \
&& PRE_COMMIT_HOME=/opt/.pre-commit-cache-prebuilt pre-commit install-hooks \
&& sudo rm -rf /fake-repo \
&& sudo chmod -R a+rwx /opt/.pre-commit-cache-prebuilt \
;