Skip to content

Commit

Permalink
update to work with new tsltools and also fix docker which for some r…
Browse files Browse the repository at this point in the history
…eason wasnt working
  • Loading branch information
santolucito committed Feb 29, 2024
1 parent 93a3c25 commit e0fab48
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@ RUN apt-get update -y && apt-get install -y\
&& apt-get clean
# [END run_system_package_alpine]
# [END cloudrun_system_package_alpine]
RUN apt-get install libpcre3 libpcre3-dev -y
RUN wget -qO- https://get.haskellstack.org/ | sh
RUN git clone https://github.com/Barnard-PL-Labs/tsltools
RUN cd tsltools && make

RUN wget -q -O - https://www.lrde.epita.fr/repo/debian.gpg | apt-key add -
RUN echo 'deb http://www.lrde.epita.fr/repo/debian/ stable/' >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y spot
RUN apt-get install -y unzip

RUN mkdir deps-src
RUN wget -P deps-src https://github.com/cvc5/cvc5/releases/download/cvc5-1.1.1/cvc5-Linux-static.zip
RUN unzip deps-src/cvc5-Linux-static.zip -d deps-src
RUN chmod a+x deps-src/cvc5-Linux-static/bin/cvc5
RUN mv deps-src/cvc5-Linux-static/bin/cvc5 /usr/bin

RUN apt-get install libpcre3 libpcre3-dev -y
RUN wget -qO- https://get.haskellstack.org/ | sh
RUN git clone https://github.com/Barnard-PL-Labs/tsltools
WORKDIR /usr/src/app/tsltools
RUN stack install
RUN cp /root/.local/bin/tsl /usr/bin

# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ To test locally

then go to localhost:8080. note that this only works with port 8080

to test, run this in the command line

```
curl -X POST http://localhost:8080/tslsynth -d 'tsl=always%20assume%20{}%0Aalways%20guarantee%20{%0A%20%20F%20([x%20<-%20y]);%0A%20%20F%20([x%20<-%20z]);%0A}&target=js&user=1}' -H 'Content-Type: application/x-www-form-urlencoded'
```


to deploy

```
docker build -t tsl/api .
gcloud builds submit --tag gcr.io/tslapi-2/tsl --timeout=1h
gcloud run deploy graphviz-web --image gcr.io/tslapi-2/tsl
gcloud config set project tslapi-2
gcloud builds submit --tag gcr.io/tslapi-2/tsl --timeout=1h && gcloud run deploy graphviz-web --image gcr.io/tslapi-2/tsl
```

you need to set a longer time out since it takes so long to build (30 min maybe?).
Expand Down
14 changes: 7 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const {execSync} = require('child_process');
const { execSync } = require('child_process');
const fs = require('fs');

const express = require('express');
Expand All @@ -28,12 +28,12 @@ app.use(require('body-parser').urlencoded({ extended: false }));
//fs.accessSync('/usr/bin/dot', fs.constants.X_OK);

app.get('/', (req, res) => {
res.send("hello tsl. go to /tslsynth to make a request");
res.send("hello tsl. go to /tslsynth to make a request");
});

// [START cloudrun_system_package_handler]
// [START run_system_package_handler]
app.post('/tslsynth', function(req, res){
app.post('/tslsynth', function (req, res) {
var tsl = req.body.tsl;
var target = req.body.target;
var user = req.body.user;
Expand Down Expand Up @@ -97,13 +97,13 @@ const createDiagram = (tsl, target) => {
target = "js"
}
try {
fs.writeFileSync('tsltools/tmp.tsl', tsl)
fs.writeFileSync('/usr/src/app/tsltools/tmp.tsl', tsl)
} catch (err) {
console.error(err)
}
const synthResult = execSync(`./tslsynth tmp.tsl --`+target, {
cwd: "./tsltools",

const synthResult = execSync(`tsl synthesize -i tmp.tsl --` + target, {
cwd: "/usr/src/app/tsltools",
input: tsl,
});

Expand Down

0 comments on commit e0fab48

Please sign in to comment.