Skip to content

Commit

Permalink
feat: Add build-dev-container workflow and Ubuntu devcontainer
Browse files Browse the repository at this point in the history
- Added a new workflow file `build-dev-container.yaml` to build the development container.
- Created a new devcontainer configuration file `devcontainer.json` for Ubuntu.
- The workflow sets up a matrix based on subfolders in the templates directory.
- The build step now uses the subfolder from the matrix to specify the template and image name.

This commit adds support for building the development container and includes an initial configuration for Ubuntu.
  • Loading branch information
npv2k1 committed Feb 2, 2024
1 parent 918fa53 commit 27cb087
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/build-dev-container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,28 @@ on: # rebuild any PRs and main branch changes
- master

jobs:
build:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v3

- name: Set matrix for build
id: set-matrix
run: |
FOLDERS=$(ls -d templates/*/)
FOLDERS=${FOLDERS//\//} # remove trailing slashes
FOLDERS=${FOLDERS//templates\//} # remove leading 'templates/'
FOLDERS_JSON=$(echo "$FOLDERS" | jq -R -s -c 'split("\n")[:-1]')
echo "::set-output name=matrix::${FOLDERS_JSON}"
build:
runs-on: ubuntu-latest
strategy:
matrix:
subfolder: ${{fromJson(needs.prepare.outputs.matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -29,7 +47,7 @@ jobs:
- name: Build and run Dev Container task
uses: devcontainers/[email protected]
with:
subFolder: ./templates/react-native
imageName: ghcr.io/pnstack/codespace/react-native
subFolder: ./templates/${{ matrix.subfolder }}
imageName: ghcr.io/pnstack/codespace/${{ matrix.subfolder }}
platform: linux/amd64,linux/arm64
push: always
21 changes: 21 additions & 0 deletions templates/ubuntu/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"runArgs": ["--device=/dev/net/tun"],
"features": {},

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

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root"
}

0 comments on commit 27cb087

Please sign in to comment.