Skip to content

Commit

Permalink
Merge pull request #107 from FreeTAKTeam/bugfix/container-fixes
Browse files Browse the repository at this point in the history
Fixing errors with the containers
- Variables not set in scripts
- Start script missing
- Other various fixes that were preventing container startup
  • Loading branch information
RadioAndrea authored Jan 11, 2024
2 parents a439d20 + e4cf061 commit 50e8a1b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
16 changes: 16 additions & 0 deletions containers/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ services:
build:
context: .
dockerfile: core-pypi.Dockerfile
ports:
# DataPackagePort
- 8080:8080
# CoTPort
- 8087:8087
# SSLCoTPort
- 8089:8089
# SSLDataPackagePort
- 8443:8443
# FederationPort
#- 9000:9000
# APIPort - Don't expose by default
#- 19023:19023
volumes:
# Confused about the Z at the end?
# on hosts with selinux, you will need this.
Expand All @@ -21,7 +34,10 @@ services:
context: .
dockerfile: ui-pypi.Dockerfile
ports:
# Web interface port
- 5000:5000
# API Port - probably don't need to expose if UI and Core are on same container network
#- 19023:19023
volumes:
- ./ui-config:/home/freetak/data:rw,Z
network_mode: "host"
20 changes: 1 addition & 19 deletions containers/core-pypi.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,14 @@ COPY --chown=freetak:freetak --chmod=774 core-run.sh ./
ENV FTS_DATA_PATH = "/opt/fts/"

# Install pre-reqs then the base FTS
# ruamel.yaml is very ornery and has to be force-reinstalled alone
# ruamel.yaml is very ornery and has to be force-reinstalled alone until the pip deps are updated
ENV PATH /home/freetak/.local/bin:$PATH
RUN pip install --upgrade pip ; pip install --force-reinstall "ruamel.yaml<0.18"
RUN pip install FreeTAKServer

# Provide a way to edit the configuration from outside the container
# May need to be updated if the base image changes
RUN cp $(python -m site --user-site)/FreeTAKServer/core/configuration/MainConfig.py $(python -m site --user-site)/FreeTAKServer/core/configuration/MainConfig.bak
RUN mv $(python -m site --user-site)/FreeTAKServer/core/configuration/MainConfig.py /opt/fts/MainConfig.py
RUN ln -s /opt/fts/MainConfig.py $(python -m site --user-site)/FreeTAKServer/core/configuration/MainConfig.py

# Open ports
# note: docker compose documentation suggests that communication between
# core and ui doesn't need a port explicitly exposed
# DataPackagePort
EXPOSE 8080
# CoTPort
EXPOSE 8087
# SSLCoTPort
EXPOSE 8089
# SSLDataPackagePort
EXPOSE 8443
# FederationPort
EXPOSE 9000
# APIPort - Don't expose by default
#EXPOSE 19023

VOLUME /opt/fts

Expand Down
12 changes: 11 additions & 1 deletion containers/core-run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
#!/bin/bash

PYTHON_USER_SITE=$(python -m site --user-site)
# Detect and navigate to the python user site packages
# Some systems use `python3` instead of `python` so this is not entirely portable
cd "${PYTHON_USER_SITE}/FreeTAKServer/" || raise error "Could not navigate to the user-sites path. Are you using a distro that requires python3 instead of python?"

# Sharing for MainConfig.py
if [[ ! -f "/opt/fts/MainConfig.py" ]]
then
cp ${PYTHON_USER_SITE}/FreeTAKServer/core/configuration/MainConfig.bak /opt/fts/MainConfig.py
fi
if [[ ! -f "${PYTHON_USER_SITE}/FreeTAKServer/core/configuration/MainConfig.py" ]]
then
ln -s /opt/fts/MainConfig.py ${PYTHON_USER_SITE}/FreeTAKServer/core/configuration/MainConfig.py
if [[ ! -f "/opt/fts/MainConfig.py" ]]
then
echo "MainConfig.py is missing from the expected volume!"
else
ln -s /opt/fts/MainConfig.py "${PYTHON_USER_SITE}/FreeTAKServer/core/configuration/MainConfig.py"
fi
fi

# Sharing for FTSConfig.yaml
Expand Down
7 changes: 4 additions & 3 deletions containers/ui-pypi.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ FROM python:3.11
RUN groupadd -r freetak && useradd -m -r -g freetak freetak

RUN mkdir -p /home/freetak/data && chown -R freetak:freetak /home/freetak/data && chmod 777 -R /home/freetak/data && chmod g+s /home/freetak/data
RUN ln -s /opt/FTSServer-UI.db /home/freetak/data/FTSServer-UI.db

# Link /opt to home data, as default configs put the db in /opt
RUN ln -s /opt/ /home/freetak/data/

USER freetak
WORKDIR /home/freetak/data

# Install pre-reqs then the base FTS
ENV PATH /home/freetak/.local/bin:/home/freetak/.local/lib:$PATH

# flask_cors is missing from the pip imports, so install it manually
RUN pip install "flask_cors"
RUN pip install FreeTAKServer-UI

Expand All @@ -20,7 +23,5 @@ RUN mv $(python -m site --user-site)/FreeTAKServer-UI/config.py $(python -m site
WORKDIR /home/freetak
COPY --chown=freetak:freetak --chmod=774 ui-run.sh ./

EXPOSE 5000/tcp
EXPOSE 19023/tcp
VOLUME /home/freetak/data
CMD ["/home/freetak/ui-run.sh"]
1 change: 1 addition & 0 deletions containers/ui-run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

PYTHON_USER_SITE=$(python -m site --user-site)
# Detect and navigate to the python user site packages
# Some systems use `python3` instead of `python` so this is not entirely portable
Expand Down

0 comments on commit 50e8a1b

Please sign in to comment.