Skip to content

Commit 27cb087

Browse files
committed
feat: Add build-dev-container workflow and Ubuntu devcontainer
- 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.
1 parent 918fa53 commit 27cb087

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

.github/workflows/build-dev-container.yaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,28 @@ on: # rebuild any PRs and main branch changes
66
- master
77

88
jobs:
9-
build:
9+
prepare:
1010
runs-on: ubuntu-latest
11+
outputs:
12+
matrix: ${{ steps.set-matrix.outputs.matrix }}
1113
steps:
14+
- name: Checkout (GitHub)
15+
uses: actions/checkout@v3
1216

17+
- name: Set matrix for build
18+
id: set-matrix
19+
run: |
20+
FOLDERS=$(ls -d templates/*/)
21+
FOLDERS=${FOLDERS//\//} # remove trailing slashes
22+
FOLDERS=${FOLDERS//templates\//} # remove leading 'templates/'
23+
FOLDERS_JSON=$(echo "$FOLDERS" | jq -R -s -c 'split("\n")[:-1]')
24+
echo "::set-output name=matrix::${FOLDERS_JSON}"
25+
build:
26+
runs-on: ubuntu-latest
27+
strategy:
28+
matrix:
29+
subfolder: ${{fromJson(needs.prepare.outputs.matrix)}}
30+
steps:
1331
- name: Checkout
1432
uses: actions/checkout@v4
1533

@@ -29,7 +47,7 @@ jobs:
2947
- name: Build and run Dev Container task
3048
uses: devcontainers/[email protected]
3149
with:
32-
subFolder: ./templates/react-native
33-
imageName: ghcr.io/pnstack/codespace/react-native
50+
subFolder: ./templates/${{ matrix.subfolder }}
51+
imageName: ghcr.io/pnstack/codespace/${{ matrix.subfolder }}
3452
platform: linux/amd64,linux/arm64
3553
push: always
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
3+
{
4+
"name": "Ubuntu",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/base:jammy",
7+
"runArgs": ["--device=/dev/net/tun"],
8+
"features": {},
9+
10+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
11+
// "forwardPorts": [],
12+
13+
// Use 'postCreateCommand' to run commands after the container is created.
14+
// "postCreateCommand": "uname -a",
15+
16+
// Configure tool-specific properties.
17+
// "customizations": {},
18+
19+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
20+
"remoteUser": "root"
21+
}

0 commit comments

Comments
 (0)