Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alternative Dockerfile #206

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tools/standalone-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# docker build --tag script-server-local --file Dockerfile_standalone .
# docker run -p 5000:5000 script-server-local
FROM ubuntu:18.04

RUN apt-get update \
&& apt-get install -y python3-pip python3-dev wget curl unzip

RUN wget `curl -s https://api.github.com/repos/bugy/script-server/releases/latest | grep browser_download_url | cut -d '"' -f 4` \
&& unzip script-server.zip -d app

WORKDIR app

RUN pip3 install -r requirements.txt

ENTRYPOINT [ "python3", "launcher.py"]
19 changes: 19 additions & 0 deletions tools/standalone-docker/config/guess_number.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Guess a number",
"script_path": "/app/scripts/guess_number.py",
"parameters": [
{
"name": "max number",
"type": "int",
"min": 1,
"required": true,
"max": 100
},
{
"name": "max gueses",
"type": "int",
"min": 1,
"max": 5
}
]
}
1 change: 1 addition & 0 deletions tools/standalone-docker/docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build --tag script-server .
1 change: 1 addition & 0 deletions tools/standalone-docker/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run -v `dirname $0 | pwd`/../../samples/configs:/app/conf/runners -v `dirname $0 | pwd`/../../samples/scripts:/app/samples/scripts -p 5000:5000 script-server
33 changes: 33 additions & 0 deletions tools/standalone-docker/scripts/guess_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/python3

import random
import sys

max_number = int(sys.argv[1])
if len(sys.argv) > 2 and sys.argv[2]:
gueses = int(sys.argv[2])
else:
gueses = 3

gueses_left = 3

number = random.randint(0, max_number)

print('Try to guess a number between 0 and ' + str(max_number) + ' (' + str(gueses_left) + ' tries):')
while gueses_left > 0:
user_input = input()
try:
user_input = int(user_input)
except:
print(user_input + ' is not really a number, please try again')

if user_input == number:
print('Congratulations, you guessed right!')
sys.exit(0)
print('Oops, the wrong choice.', end='')
gueses_left -= 1
if gueses_left:
print('. Try again:')

print('\nTry you luck next time!')