Skip to content

Commit

Permalink
added docker config and initial front end components.
Browse files Browse the repository at this point in the history
  • Loading branch information
njfio committed Aug 21, 2024
1 parent 97ecec3 commit 82994d4
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
35 changes: 35 additions & 0 deletions fluent-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM alpine:latest

RUN apk update && apk upgrade

RUN apk add jq
RUN apk add pandoc

RUN apk add --no-cache build-base bash git curl wget python3 python3-dev py3-pip \
ruby ruby-dev ruby-irb ruby-rdoc ruby-json ruby-bigdecimal

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Install Fluent CLI
RUN cargo install --git https://github.com/njfio/fluent_cli fluent

RUN cargo install --git https://github.com/fpco/amber amber

RUN pip install flask

COPY ./frontend /app/frontend

EXPOSE 5000

CMD ["flask", "run", "--host=0.0.0.0"]

RUN mkdir /.fluent/
RUN cp ~/.cargo/git/checkouts/fluent_cli-*/*/default_config_test.json /.fluent/
RUN cp ~/.cargo/git/checkouts/fluent_cli-*/*/fluent_autocomplete.sh /.fluent/
RUN cp ~/.cargo/git/checkouts/fluent_cli-*/*/amber.yaml /.fluent/

# Set up Entrypoint
ENTRYPOINT ["bash"]
RUN echo "source /.fluent/fluent_autocomplete.sh" >> ~/.bashrc
3 changes: 3 additions & 0 deletions fluent-env/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AMBER_SECRET=
AMBER_YAML=/.fluent/amber.yaml
FLUENT_CLI_V2_CONFIG_PATH=/.fluent/default_config_test.json
30 changes: 30 additions & 0 deletions front_end_index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>Fluent Web Frontend</title>
<script>
function executeCommand() {
const command = document.getElementById('command').value;
fetch('/execute', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ command: command })
})
.then(response => response.json())
.then(data => {
if (data.output) {
document.getElementById('output').innerText = data.output;
} else if (data.error) {
document.getElementById('output').innerText = "Error: " + data.error;
}
});
}
</script>
</head>
<body>
<h1>Fluent Web Frontend</h1>
<input type="text" id="command" placeholder="Enter Fluent command">
<button onclick="executeCommand()">Execute</button>
<div id="output"></div>
</body>
</html>
20 changes: 20 additions & 0 deletions frontend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from flask import Flask, request, jsonify
import subprocess

app = Flask(__name__, static_url_path='', static_folder='frontend')

@app.route('/', methods=['GET'])
def index():
return app.send_static_file('front_end_index.html')

@app.route('/execute', methods=['POST'])
def execute_fluent():
command = request.json['command']
try:
output = subprocess.check_output(["fluent", command], shell=True).decode('utf-8')
return jsonify({'output': output})
except subprocess.CalledProcessError as e:
return jsonify({'error': str(e)})

if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')

0 comments on commit 82994d4

Please sign in to comment.