Skip to content

Commit

Permalink
fix and improve devcontainer prebuild (#737)
Browse files Browse the repository at this point in the history
* only run build, not tests

* create our own cached image in CI

* doc devcontainer

* use prebuilt devcontainer

* exclude nodle-parachain

* schedule devcontainer build for once a week
  • Loading branch information
ETeissonniere committed Apr 28, 2023
1 parent 74deb74 commit 49e6999
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# This Dockerfile is used to build the Dev Container for VSCode
# and GitHub Codespaces.
# It is based on the official VSCode Dev Container for Rust and
# pre-installs the required dependencies for the Nodle Chain
# development along with SubWasm and a prebuilt Polkadot
# binary.

FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu

USER root
Expand Down
8 changes: 6 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"build": {
"dockerfile": "Dockerfile",
"context": ".."
"context": "..",
// Prebuilt in CI/CD
"cacheFrom": "ghcr.io/nodlecode/devcontainer-chain"
},
"features": {
"github-cli": "latest",
Expand All @@ -11,7 +13,9 @@
// This run during prebuild and allows the user to start with a container
// containing the latest compiled dependencies and save on the first compilation
// cycle which is usually absurdly slow.
"updateContentCommand": "cargo test --all --no-run",
// We exclude nodle-parachain because it oftens pose problems in the constricted
// environment of the github prebuild system.
"updateContentCommand": "cargo build --all --exclude nodle-parachain",
// Ensure every codespace have the minimum resources to comfortably support the
// project.
"hostRequirements": {
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: DevContainer

on:
schedule:
- cron: '0 0 * * 0'

jobs:

build:
name: Build and cache devcontainer image
runs-on: ubuntu-latest

steps:

- name: Check out the repo
uses: actions/checkout@v2

- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pre-build dev container image
uses: devcontainers/ci@v0.3
with:
imageName: ghcr.io/nodlecode/devcontainer-chain
cacheFrom: ghcr.io/nodlecode/devcontainer-chain
push: always

0 comments on commit 49e6999

Please sign in to comment.