Add scorometer dockerfile
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
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"]
|
||||
4
scorometer/main.py
Normal file → Executable file
4
scorometer/main.py
Normal file → Executable 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,6 +79,7 @@ class Scorometer():
|
||||
self.sendEnd(0, {})
|
||||
|
||||
def main():
|
||||
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"}))
|
||||
@@ -85,6 +87,8 @@ def main():
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user