Add scorometer dockerfile
This commit is contained in:
@@ -7,3 +7,7 @@ trim_trailing_whitespace = true
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = tab
|
indent_size = tab
|
||||||
|
|
||||||
|
[{*.yaml,*.yml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|||||||
@@ -14,6 +14,16 @@ services:
|
|||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
|
||||||
|
scorometer:
|
||||||
|
build:
|
||||||
|
context: ./scorometer
|
||||||
|
dockerfile: Dockerfile.dev
|
||||||
|
ports:
|
||||||
|
- "6543:6543"
|
||||||
|
volumes:
|
||||||
|
- ./scorometer:/app
|
||||||
|
- ./musics:/musics
|
||||||
|
|
||||||
db:
|
db:
|
||||||
container_name: db
|
container_name: db
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ services:
|
|||||||
- .env
|
- .env
|
||||||
volumes:
|
volumes:
|
||||||
- ./musics:/musics
|
- ./musics:/musics
|
||||||
|
scorometer:
|
||||||
|
build: ./scorometer
|
||||||
|
ports:
|
||||||
|
- "6543:6543"
|
||||||
|
volumes:
|
||||||
|
- ./musics:/musics
|
||||||
db:
|
db:
|
||||||
container_name: db
|
container_name: db
|
||||||
image: postgres:alpine3.14
|
image: postgres:alpine3.14
|
||||||
|
|||||||
3
scorometer/.dockerignore
Normal file
3
scorometer/.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Dockerfile
|
||||||
|
Dockerfile.dev
|
||||||
|
.dockerignore
|
||||||
13
scorometer/Dockerfile
Normal file
13
scorometer/Dockerfile
Normal 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
12
scorometer/Dockerfile.dev
Normal 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
18
scorometer/main.py
Normal file → Executable file
@@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from chroma_case.Partition import Partition
|
from chroma_case.Partition import Partition
|
||||||
from chroma_case.Note import Note
|
from chroma_case.Note import Note
|
||||||
@@ -78,13 +79,16 @@ class Scorometer():
|
|||||||
self.sendEnd(0, {})
|
self.sendEnd(0, {})
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
start_message = json.loads(input())
|
try:
|
||||||
if start_message["type"] != "start" or "name" not in start_message.keys():
|
start_message = json.loads(input())
|
||||||
print(json.dumps({"error": "Error with the start message"}))
|
if start_message["type"] != "start" or "name" not in start_message.keys():
|
||||||
exit()
|
print(json.dumps({"error": "Error with the start message"}))
|
||||||
song_name = start_message["name"]
|
exit()
|
||||||
sc = Scorometer(f"partitions/{song_name}.midi")
|
song_name = start_message["name"]
|
||||||
sc.gameLoop()
|
sc = Scorometer(f"partitions/{song_name}.midi")
|
||||||
|
sc.gameLoop()
|
||||||
|
except Exception as error:
|
||||||
|
print({ "error": error })
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user