Skip to content

Commit b1e32a8

Browse files
Setup GitHub Actions workflow for building and pushing runner image
1 parent 649353c commit b1e32a8

21 files changed

Lines changed: 606 additions & 19 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ on:
55
branches:
66
- main
77
- Dev
8+
-week02-devops
9+
810
pull_request:
911
branches:
1012
- main
1113
- Dev
14+
-week02-devops
1215

1316
jobs:
1417
# Frontend Build Job

.github/workflows/runner-image.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build & Push Runner Image
2+
3+
on:
4+
push:
5+
paths:
6+
- "runner/**"
7+
- ".github/workflows/runner-image.yml"
8+
9+
jobs:
10+
build-runner:
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- name: Checkout repo
19+
uses: actions/checkout@v4
20+
21+
- name: Log in to GHCR
22+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
23+
24+
- name: Build runner image
25+
run: |
26+
docker build \
27+
-t ghcr.io/${{ github.repository_owner | toLower }}/nebula-runner:latest \
28+
./runner
29+
30+
- name: Push runner image
31+
run: |
32+
docker push ghcr.io/${{ github.repository_owner | toLower }}/nebula-runner:latest

backend/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ RUN npm install --production
3535

3636
COPY --from=builder /app/dist ./dist
3737

38+
COPY --from=builder /app/workspaces-data ./workspaces-data
39+
3840
# Set environment variables (optional, can be set in Render dashboard)
3941

4042
ENV NODE_ENV=production

backend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
109109

110110
```bash
111111
npm run start:dev
112-
curl http://localhost:4000/workspaces/demo-workspace/files/welcome-file | jq
112+
curl http://localhost:4000/workspaces/demo-workspace/files/-file | jq
113113
```
114114

115115
You should see the demo TypeScript file payload in the response and a corresponding `[HTTP] GET ... 200` log entry in the server console.

backend/src/app.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export class AppController {
99
getHello(): string {
1010
return this.appService.getHello();
1111
}
12+
1213
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// src/runner/docker.service.ts
21
import Docker from 'dockerode';
32

4-
export const docker = new Docker({
5-
socketPath: '/var/run/docker.sock',
6-
});
3+
export const docker = new Docker({ socketPath: '/var/run/docker.sock' });

backend/src/runner/runner.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class RunnerController {
99
@Post('spawn')
1010
async run() {
1111
const runId = randomUUID();
12-
await this.runnerService.spawn('nebula-runner:week2', runId);
12+
await this.runnerService.spawn('ghcr.io/hesara2003/nebula-runner:latest', runId);
1313
return { runId, status: 'running' };
1414
}
1515
}

backend/src/runner/runner.service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class RunnerService {
77
const container = await docker.createContainer({
88
Image: image,
99
User: 'runner',
10-
Cmd: ['timeout', '10s', 'node', 'index.js'],
10+
Cmd: ['timeout', '10s', 'node', 'src/index.js'],
1111
Labels: { runId },
1212
HostConfig: {
1313
AutoRemove: true,
@@ -19,5 +19,10 @@ export class RunnerService {
1919

2020
await container.start();
2121
return container;
22+
23+
}
24+
catch (err) {
25+
console.error('Failed to spawn container:', err);
26+
throw err;
2227
}
2328
}

backend/src/storage/storage.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class StorageService implements OnModuleInit {
3535
} catch {
3636
await fs.mkdir(workspacePath, { recursive: true });
3737
// Create a default file
38-
await this.saveFile(workspaceId, 'src/welcome.ts', `// Welcome to NebulaCode workspace: ${workspaceId}\nconsole.log("Hello World");`);
38+
await this.saveFile(workspaceId, 'welcome-file', `// Welcome to NebulaCode workspace: ${workspaceId}\nconsole.log("Hello World");`);
3939
}
4040
}
4141

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Welcome to the demo workspace!
2+
This is your starting file.

0 commit comments

Comments
 (0)