Add scorometer dockerfile

This commit is contained in:
Zoe Roux
2022-12-21 16:28:21 +09:00
committed by GitBluub
parent 4fdb825c60
commit 78496a5223
7 changed files with 59 additions and 7 deletions

View File

@@ -7,3 +7,7 @@ trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = tab
[{*.yaml,*.yml}]
indent_style = space
indent_size = 2

View File

@@ -15,6 +15,16 @@ services:
env_file:
- .env
scorometer:
build:
context: ./scorometer
dockerfile: Dockerfile.dev
ports:
- "6543:6543"
volumes:
- ./scorometer:/app
- ./musics:/musics
db:
container_name: db
image: postgres:alpine3.14

View File

@@ -10,6 +10,12 @@ services:
- .env
volumes:
- ./musics:/musics
scorometer:
build: ./scorometer
ports:
- "6543:6543"
volumes:
- ./musics:/musics
db:
container_name: db
image: postgres:alpine3.14

3
scorometer/.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
Dockerfile
Dockerfile.dev
.dockerignore

13
scorometer/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM python:latest
RUN wget -q -O /tmp/websocketd.zip \
https://github.com/joewalnes/websocketd/releases/download/v0.4.1/websocketd-0.4.1-linux_amd64.zip \
&& unzip /tmp/websocketd.zip -d /tmp/websocketd && mv /tmp/websocketd/websocketd /usr/bin \
&& chmod +x /usr/bin/websocketd
WORKDIR /app
COPY ./requirements.txt .
RUN pip install -r ./requirements.txt
COPY . .
CMD ["/usr/bin/websocketd", "--port=6543", "--staticdir=." "./main.py"]

12
scorometer/Dockerfile.dev Normal file
View File

@@ -0,0 +1,12 @@
FROM python:latest
RUN wget -q -O /tmp/websocketd.zip \
https://github.com/joewalnes/websocketd/releases/download/v0.4.1/websocketd-0.4.1-linux_amd64.zip \
&& unzip /tmp/websocketd.zip -d /tmp/websocketd && mv /tmp/websocketd/websocketd /usr/bin \
&& chmod +x /usr/bin/websocketd
WORKDIR /app
COPY ./requirements.txt .
RUN pip install -r ./requirements.txt
CMD ["/usr/bin/websocketd", "--port=6543", "--devconsole", "--", "python3", "./main.py"]

18
scorometer/main.py Normal file → Executable file
View File

@@ -1,3 +1,4 @@
#!/usr/bin/python3
from time import sleep
from chroma_case.Partition import Partition
from chroma_case.Note import Note
@@ -78,13 +79,16 @@ class Scorometer():
self.sendEnd(0, {})
def main():
start_message = json.loads(input())
if start_message["type"] != "start" or "name" not in start_message.keys():
print(json.dumps({"error": "Error with the start message"}))
exit()
song_name = start_message["name"]
sc = Scorometer(f"partitions/{song_name}.midi")
sc.gameLoop()
try:
start_message = json.loads(input())
if start_message["type"] != "start" or "name" not in start_message.keys():
print(json.dumps({"error": "Error with the start message"}))
exit()
song_name = start_message["name"]
sc = Scorometer(f"partitions/{song_name}.midi")
sc.gameLoop()
except Exception as error:
print({ "error": error })
if __name__ == "__main__":
main()