Skip to content

Commit

Permalink
Initial Docker implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiesonpepper committed Dec 3, 2024
1 parent 57c85bb commit 90e37f8
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
##############################################################################
# Install App
##############################################################################
FROM python:3.14.0a2-alpine3.20
WORKDIR /spatialmediatools/app
ENV PATH="${PATH}:/spatialmediatools/app"

RUN apk update && \
apk upgrade && \
apk --no-cache add --virtual wget unzip ca-certificates

COPY ./requirements.txt /spatialmediatools/app/requirements.txt
RUN python -m venv spatialmediatools
RUN source spatialmediatools/bin/activate
RUN spatialmediatools/bin/python -m pip install --upgrade pip
RUN spatialmediatools/bin/python -m pip install -r requirements.txt
RUN spatialmediatools/bin/python -m pip install -I gunicorn

COPY ./app.py /spatialmediatools/app
COPY ./wsgi.py /spatialmediatools/app
COPY ./startup.sh /spatialmediatools/app
RUN chmod 777 /spatialmediatools/app/startup.sh
RUN mkdir ./data

##############################################################################
# Download and extract Spatial Metadata Tools Code
##############################################################################
ENV GIT_URL="https://github.com/google/spatial-media/archive/refs/heads/master.zip"
ENV APP_DIR="/spatialmediatools/app"

RUN wget --no-check-certificate -O spatialmediatools.zip $GIT_URL;
RUN unzip $APP_DIR/spatialmediatools.zip;

##############################################################################
# Clean up of unneeded packages and download
##############################################################################
RUN rm -rf /var/cache/apk/*;
RUN rm $APP_DIR/spatialmediatools.zip
RUN apk del wget unzip ca-certificates;

##############################################################################
# Run app.py
##############################################################################
#CMD [ "spatialmediatools/bin/python", "app.py" ]
ENTRYPOINT [ "/spatialmediatools/app/startup.sh" ]
33 changes: 33 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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.

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.

To build this image clone this repository to a machine with Docker installed and run the following:

`docker build -t spatialmedia/tools .`

To run this image newly built image in Docker use the following command:

**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.

```
docker run -it \
-p 8888:5000 \
--net=bridge \
-h spatialmedia \
--name SpatialMediaTools \
-v /path/to/OS/folder:/spatialmediatools/app/data \
-d spatialmedia/tools
```

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:

`docker exec -it SpatialMediaTools sh`

Change to the directory where the code was installed to in the image:

`cd spatial-media-master`

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:

`python spatialmedia -i /spatialmediatools/app/data/<name_of_input_file.ext> /spatialmediatools/app/data/<name_of_output_file.ext>`
9 changes: 9 additions & 0 deletions docker/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"

if __name__ == "__main__":
app.run(host='0.0.0.0')
2 changes: 2 additions & 0 deletions docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Flask
gunicorn
2 changes: 2 additions & 0 deletions docker/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
/spatialmediatools/app/spatialmediatools/bin/gunicorn wsgi:app -w 2 --threads 2 -b 0.0.0.0:5000
4 changes: 4 additions & 0 deletions docker/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from app import app

if __name__ == "__main__":
app.run()

0 comments on commit 90e37f8

Please sign in to comment.