Skip to content

Commit 4108825

Browse files
committed
get ready for release
1 parent b01613e commit 4108825

File tree

8 files changed

+167
-14
lines changed

8 files changed

+167
-14
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
# duino.app Docker Compile Server
22
## aka Chromeduino 3.0
33

4-
# Notice: This is a work in progress and may not currently work.
4+
This server acts as an interface between the duino.app client and the arduino-cli.
5+
6+
The main purpose of this is to let arduino-cli handle most of the code compiling work.
7+
8+
The main update made in 3.0 is the websocket interface, which gives real-time communication with
9+
the client, allowing us to proxy the serial connection to the device for uploading.
10+
11+
It's important to note that this server is bundled using docker with **All** the libraries installed,
12+
this allows anyone to use any library they desire by simply including it. The down side of this is
13+
that the servers docker-bundle size is several gigabytes in size.
14+
15+
## Installing a local compile server
16+
17+
**Warning:** The server download is serveral gigabytes in size, initial installation will take a while.
18+
19+
1. Make sure [docker is installed.](https://docs.docker.com/engine/install/)
20+
2. run `docker run -p 3030:3030 --restart always -d duinoapp/duinoapp-server:latest`
21+
22+
The compile server will be available at `http://localhost:3030`
23+
24+
## Making a server accessable remotely
25+
26+
If you've installed this on an existing server, just setup a reverse proxy to `http://localhost:3030`.
27+
28+
Alternatively, you can setup this on a fresh server by following [these instructions.](link)
29+
30+
If you have no clue what I'm talking about, reachout for help.

base-all/data/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
arduino/

base-all/data/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ USER root
44
RUN useradd duino
55

66
COPY setup /home/duino/setup
7-
COPY data /home/duino/data
7+
# COPY data /home/duino/data
88
# COPY Arduino /home/duino/Arduino
99

1010
RUN chown duino:duino /home/duino -R
@@ -13,8 +13,9 @@ RUN apt-get update && apt-get install build-essential
1313
WORKDIR /home/duino
1414
USER duino
1515

16-
RUN wget https://github.com/arduino/arduino-cli/releases/download/0.9.0/arduino-cli_0.9.0_Linux_64bit.tar.gz -O - | tar -xz
16+
RUN wget https://github.com/arduino/arduino-cli/releases/download/0.13.0/arduino-cli_0.13.0_Linux_64bit.tar.gz -O - | tar -xz
1717

18+
RUN mkdir data
1819
RUN ls
1920

2021
ENV CLI_ARGS="--config-file /home/duino/data/arduino-cli.yml --format json"

deployment/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Remote deployment
2+
3+
Theses are some files to help make deploying on a remote server easier.
4+
This assumes a fresh VPS with Ubuntu 20 +, that is only going to be used as
5+
a compile server. A minimum of 20GB of storage is required.
6+
7+
VPS = Virtual Private Server
8+
9+
1. Create the VPS, Digital Ocean droplets are usually good for beginners (cheapest will do)
10+
2. Point your subdomain to the VPS (this will be an A record with the VPS's public IP)
11+
3. SSH into the VPS, you can usually do this from the Digital Ocean web interface.
12+
4. Run the command `<insert command here>` (This will take a while)
13+
5. Run the command `nano docker-compose.yml`
14+
6. Edit the content of the file where indicated, you should enter details like the domain, subdomain, email, server info
15+
7. When done editing, press `Ctl+X`, `Y`, and then `Enter`
16+
8. Run `docker-compose up -d`
17+
18+
The server should now be available on your subdomain.
19+
20+
## I Have No Clue What You Just Said
21+
22+
That's ok. Feel free to reach out. If you want to add a new public compile server, we can help you with everything.

deployment/default

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## duinoapp proxy config
2+
3+
# redirect all traffic to https
4+
server {
5+
listen 80 default_server;
6+
listen [::]:80 default_server;
7+
server_name _;
8+
return 301 https://$host$request_uri;
9+
}
10+
11+
# main server block
12+
server {
13+
listen 443 ssl http2 default_server;
14+
listen [::]:443 ssl http2 default_server;
15+
16+
server_name _;
17+
18+
# enable subfolder method reverse proxy confs
19+
include /config/nginx/proxy-confs/*.subfolder.conf;
20+
21+
# all ssl related config moved to ssl.conf
22+
include /config/nginx/ssl.conf;
23+
24+
client_max_body_size 0;
25+
26+
location / {
27+
proxy_set_header Host $host;
28+
proxy_set_header X-Real-IP $remote_addr;
29+
proxy_pass http://duinoapp:3030;
30+
proxy_set_header X-Forwarded-Proto $scheme;
31+
proxy_http_version 1.1;
32+
proxy_set_header Upgrade $http_upgrade;
33+
proxy_set_header Connection "upgrade";
34+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
35+
proxy_read_timeout 3m;
36+
proxy_send_timeout 3m;
37+
}
38+
39+
}
40+
41+
42+
# enable subdomain method reverse proxy confs
43+
include /config/nginx/proxy-confs/*.subdomain.conf;
44+
# enable proxy cache for auth
45+
proxy_cache_path cache/ keys_zone=auth_cache:10m;

deployment/docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: "2.1"
2+
services:
3+
swag:
4+
image: linuxserver/swag
5+
container_name: swag
6+
cap_add:
7+
- NET_ADMIN
8+
environment:
9+
- PUID=1000
10+
- PGID=1000
11+
- URL=duino.app # update this, main domain
12+
- SUBDOMAINS=au # update this, subdomain of compile server
13+
- VALIDATION=http
14+
- [email protected] # update this, contact email for letsencrypt incase something goes wrong
15+
- ONLY_SUBDOMAINS=true # update this, only encypt subdomains (au.duino.app)
16+
volumes:
17+
- /home/ubuntu/nginx:/config # update this, location on main server for nginx configs
18+
ports:
19+
- 443:443
20+
- 80:80
21+
restart: unless-stopped
22+
links:
23+
- duinoapp
24+
duinoapp:
25+
image: duinoapp/duinoapp-server:latest
26+
container_name: duinoapp
27+
environment: # update these, server info displayed to users
28+
- SERVER_INFO_NAME="Australian Server"
29+
- SERVER_INFO_LOCATION="Australia/Sydney"
30+
- SERVER_INFO_COUNTRY="AU"
31+
- SERVER_INFO_OWNER="Duino App"
32+
- SERVER_INFO_WEBSITE="duino.app"
33+
- SERVER_INFO_DESCRIPTION="Server run on Vegemite"

deployment/init-server.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
2+
3+
sudo add-apt-repository \
4+
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
5+
$(lsb_release -cs) \
6+
stable"
7+
8+
sudo apt-get update
9+
sudo apt-get upgrade -y
10+
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
11+
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
12+
sudo chmod +x /usr/local/bin/docker-compose
13+
14+
sudo docker pull duinoapp/duinoapp-server:latest
15+

src/actions/program.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,30 @@ const program = {
99
randId: () => Math.random().toString(16).substr(2),
1010

1111
getError: (res) => {
12-
let obj;
12+
let error;
1313
try {
14-
obj = JSON.parse(res.split('\n').pop());
14+
error = JSON.parse(res.split('\n').pop());
1515
} catch (err) {
16-
return null;
16+
return {};
1717
}
18-
if (obj && obj.Cause) return obj;
19-
return null;
18+
if (error && error.Cause) return { error };
19+
return {};
2020
},
2121

22-
compile: async ({ fqbn, files }, socket, done) => {
22+
compile: async ({ fqbn, files, noHex = false }, socket, done) => {
2323
await tmpFiles.loadTempFiles(files, socket);
24-
const res = await cli('compile', ['-v', '--warnings', 'all', '--fqbn', fqbn, socket.sketchPath], socket);
24+
const res = await cli('compile', [
25+
'-v',
26+
'--warnings', 'all',
27+
'--fqbn', fqbn,
28+
...(!noHex ? ['--output', `${socket.sketchPath}/output`] : []),
29+
socket.sketchPath,
30+
], socket);
2531
const response = program.getError(res);
32+
if (!response.error && !noHex) {
33+
const hex = await fs.readFile(`${socket.sketchPath}/output.hex`, 'base64');
34+
response.hex = hex;
35+
}
2636
// tmpFiles.cleanup(socket);
2737
if (done) done(response);
2838
return response;
@@ -72,12 +82,12 @@ const program = {
7282
`${session.sketchPath}/legacy`,
7383
session.sketchPath,
7484
]);
75-
const err = program.getError(res);
76-
if (err) {
85+
const response = program.getError(res);
86+
if (response.error) {
7787
return {
7888
success: false,
79-
msg: err.Cause,
80-
code: err.Code,
89+
msg: response.error.Cause,
90+
code: response.error.Code,
8191
stdout: '',
8292
stderr: res,
8393
};

0 commit comments

Comments
 (0)