Skip to content

Commit 4be21a3

Browse files
committed
Setup code runner
1 parent 7236dc1 commit 4be21a3

File tree

10 files changed

+192
-6
lines changed

10 files changed

+192
-6
lines changed

apps/web/src/api/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ api.interceptors.response.use(
6060
);
6161

6262
export const runApi = axios.create({
63-
baseURL: 'https://code-runner.bdeak.net/run',
63+
baseURL: 'https://code-runner.dump.hr/run',
6464
timeout: 5000,
6565
headers: {
6666
'Content-Type': 'application/json',

apps/web/src/components/CodeRunner/CodeRunner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const CodeRunner: FC<Props> = ({ code, language }) => {
7878

7979
const pid = nanoid();
8080

81-
const stdout = new EventSource(`https://code-runner.bdeak.net/run/${pid}`);
81+
const stdout = new EventSource(`https://code-runner.dump.hr/run/${pid}`);
8282

8383
stdout.onmessage = ({ data }) => {
8484
const { event, text } = JSON.parse(data);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[web]
2-
49.12.103.189
2+
3.124.49.131 #promini svake godine je drugi

infrastructure/ansible/playbooks/code-runner/playbook.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
when: groups.all|length == 0
88

99
- hosts: web
10-
remote_user: root # TODO: promini
10+
remote_user: admin # TODO: promini
1111

1212
pre_tasks:
1313
- name: Update apt cache if needed.
@@ -21,9 +21,9 @@
2121
become: true
2222
vars:
2323
docker_users:
24-
- root # TODO: promini
24+
- admin # TODO: promini
2525
- role: traefik
2626
- role: code-runner
2727
vars:
2828
docker_image: ghcr.io/dump-hr/code-runner:latest
29-
code_runner_domain: code-runner.bdeak.net
29+
code_runner_domain: code-runner.dump.hr
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.5.3

infrastructure/terraform/live/production/code-runner/.terraform.lock.hcl

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
data "aws_subnets" "public_subnets" {
2+
tags = {
3+
Project = "internship-app"
4+
Role = "public"
5+
Environment = "shared"
6+
ManagedBy = "terraform"
7+
}
8+
}
9+
10+
data "aws_security_groups" "public_sg" {
11+
tags = {
12+
Project = "internship-app"
13+
Role = "public"
14+
Environment = "shared"
15+
ManagedBy = "terraform"
16+
}
17+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
terraform {
2+
required_version = ">= 1.0.0, < 2.0.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "~> 5.0"
8+
}
9+
10+
cloudflare = {
11+
source = "cloudflare/cloudflare"
12+
version = "~> 4.0"
13+
}
14+
15+
sops = {
16+
source = "carlpett/sops"
17+
version = "~> 0.5"
18+
}
19+
}
20+
}
21+
22+
provider "aws" {
23+
region = "eu-central-1"
24+
profile = "internship-app"
25+
}
26+
27+
provider "cloudflare" {
28+
api_token = data.sops_file.secrets.data["cloudflare_api_token"]
29+
}
30+
31+
data "cloudflare_zone" "dump_hr" {
32+
name = "dump.hr"
33+
}
34+
35+
data "sops_file" "secrets" {
36+
source_file = "secrets.enc.json"
37+
}
38+
39+
module "code_runner" {
40+
source = "github.com/lukazuljevic/code-runner"
41+
42+
name_prefix = "code-runner-production"
43+
instance_type = "t3a.xlarge"
44+
instance_count = 1
45+
instance_root_device_size = 20
46+
subnets = data.aws_subnets.public_subnets.ids
47+
security_groups = data.aws_security_groups.public_sg.ids
48+
ssh_public_key = file("../../../../ssh-keys/production.pub")
49+
website_domain = "code-runner.dump.hr"
50+
cloudflare_zone_id = data.cloudflare_zone.dump_hr.id
51+
52+
tags = {
53+
Project = "code-runner"
54+
Role = "code-runner"
55+
Environment = "production"
56+
}
57+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "web_ips" {
2+
value = module.code_runner.instance_ips
3+
}
4+
5+
output "web_endpoint" {
6+
value = module.code_runner.website_endpoint
7+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"cloudflare_api_token": "ENC[AES256_GCM,data:zwitfNiS7eMF2MuFvp0Uzi4BZ8i6LdvFmsGGRwoGEgEaXqZ22MdIhw==,iv:kt4rqteHRAf4CWj6cek/GwZxgbNY4I7TxBTpxTYezF4=,tag:OnKJK7g3LoFRcVCu0Yf+hw==,type:str]",
3+
"sops": {
4+
"kms": [
5+
{
6+
"arn": "arn:aws:kms:us-east-1:763640948377:alias/internship-app",
7+
"created_at": "2023-09-28T09:42:46Z",
8+
"enc": "AQICAHjrdaBMJIMrrh9887xDqCyfay6NkxFQg6tntB6xewhoWQEgRSJXP1nyJPTo6/w5EatWAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMdzy6b2lWhZG7FqFEAgEQgDv5v9vALW+pELmy/+BH6uhZiVZBIqILDEylZBAr1/ytTz7AwicuxbcgCNHSTNvoplXA/lXKg3flA63mrA==",
9+
"aws_profile": "internship-app"
10+
}
11+
],
12+
"gcp_kms": null,
13+
"azure_kv": null,
14+
"hc_vault": null,
15+
"age": null,
16+
"lastmodified": "2023-09-28T09:42:56Z",
17+
"mac": "ENC[AES256_GCM,data:MsvKuVs+Scgof1qauPA179ZVi3f2WKLAT2Woonnpt+VUMCrsd5YCLKB3Lwo7RGR9khkNyxCo4C9OnwX/deX1bKRtCQrcfjgcN1YTzFlB68nVH2TyD9ITy0N/aIgCkL1PrGy8YsKON5onrJe62Ja+SloqGZFt3yzf15oIN4l/bps=,iv:nsFZ7CmFU9XXUYTHYoXTNShbeeyyEbvOwE8UIejXcYM=,tag:LucwcYMjdxY0ZRP/WNe2/Q==,type:str]",
18+
"pgp": null,
19+
"unencrypted_suffix": "_unencrypted",
20+
"version": "3.7.3"
21+
}
22+
}

0 commit comments

Comments
 (0)