Skip to content

Commit 90e37f8

Browse files
Initial Docker implementation
1 parent 57c85bb commit 90e37f8

File tree

6 files changed

+95
-0
lines changed

6 files changed

+95
-0
lines changed

docker/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
##############################################################################
2+
# Install App
3+
##############################################################################
4+
FROM python:3.14.0a2-alpine3.20
5+
WORKDIR /spatialmediatools/app
6+
ENV PATH="${PATH}:/spatialmediatools/app"
7+
8+
RUN apk update && \
9+
apk upgrade && \
10+
apk --no-cache add --virtual wget unzip ca-certificates
11+
12+
COPY ./requirements.txt /spatialmediatools/app/requirements.txt
13+
RUN python -m venv spatialmediatools
14+
RUN source spatialmediatools/bin/activate
15+
RUN spatialmediatools/bin/python -m pip install --upgrade pip
16+
RUN spatialmediatools/bin/python -m pip install -r requirements.txt
17+
RUN spatialmediatools/bin/python -m pip install -I gunicorn
18+
19+
COPY ./app.py /spatialmediatools/app
20+
COPY ./wsgi.py /spatialmediatools/app
21+
COPY ./startup.sh /spatialmediatools/app
22+
RUN chmod 777 /spatialmediatools/app/startup.sh
23+
RUN mkdir ./data
24+
25+
##############################################################################
26+
# Download and extract Spatial Metadata Tools Code
27+
##############################################################################
28+
ENV GIT_URL="https://github.com/google/spatial-media/archive/refs/heads/master.zip"
29+
ENV APP_DIR="/spatialmediatools/app"
30+
31+
RUN wget --no-check-certificate -O spatialmediatools.zip $GIT_URL;
32+
RUN unzip $APP_DIR/spatialmediatools.zip;
33+
34+
##############################################################################
35+
# Clean up of unneeded packages and download
36+
##############################################################################
37+
RUN rm -rf /var/cache/apk/*;
38+
RUN rm $APP_DIR/spatialmediatools.zip
39+
RUN apk del wget unzip ca-certificates;
40+
41+
##############################################################################
42+
# Run app.py
43+
##############################################################################
44+
#CMD [ "spatialmediatools/bin/python", "app.py" ]
45+
ENTRYPOINT [ "/spatialmediatools/app/startup.sh" ]

docker/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
This is the first attempt at taking a different path for the Spatial Media Tools and creating a Docker container to use the [CLI commands](https://github.com/google/spatial-media/tree/master/spatialmedia#spatial-media-metadata-injector) to inject the Spatial Media metadata required for VR360/180 video with or without ambisonic audio.
2+
3+
This should remove any OS specific requirements for Python TK that are tied to different Python versions in use. It will be based on the latest available Python/Alpine image at the time of release.
4+
5+
To build this image clone this repository to a machine with Docker installed and run the following:
6+
7+
`docker build -t spatialmedia/tools .`
8+
9+
To run this image newly built image in Docker use the following command:
10+
11+
**Note:** Map an OS path in the first section of the -v flag to /app/data within the container and ensure that it has read/write access.
12+
13+
```
14+
docker run -it \
15+
-p 8888:5000 \
16+
--net=bridge \
17+
-h spatialmedia \
18+
--name SpatialMediaTools \
19+
-v /path/to/OS/folder:/spatialmediatools/app/data \
20+
-d spatialmedia/tools
21+
```
22+
23+
Once the image is running copy a file to inject to the above OS path and run the following to connect to the running image:
24+
25+
`docker exec -it SpatialMediaTools sh`
26+
27+
Change to the directory where the code was installed to in the image:
28+
29+
`cd spatial-media-master`
30+
31+
Using the [CLI commands](https://github.com/google/spatial-media/tree/master/spatialmedia#spatial-media-metadata-injector) as a reference attempt to inject the spatial media metadata into the video file you copied to the above path. Example:
32+
33+
`python spatialmedia -i /spatialmediatools/app/data/<name_of_input_file.ext> /spatialmediatools/app/data/<name_of_output_file.ext>`

docker/app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from flask import Flask
2+
app = Flask(__name__)
3+
4+
@app.route("/")
5+
def hello():
6+
return "<h1 style='color:blue'>Hello There!</h1>"
7+
8+
if __name__ == "__main__":
9+
app.run(host='0.0.0.0')

docker/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask
2+
gunicorn

docker/startup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
/spatialmediatools/app/spatialmediatools/bin/gunicorn wsgi:app -w 2 --threads 2 -b 0.0.0.0:5000

docker/wsgi.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from app import app
2+
3+
if __name__ == "__main__":
4+
app.run()

0 commit comments

Comments
 (0)