Skip to content

Commit

Permalink
Working on v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdalertdk committed Jun 20, 2024
1 parent 6ef65c2 commit bff9f58
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
*

# Whitelist these files
!entrypoint.d/
!healthcheck.py
!__init__.py
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ RUN python3 -m venv /app/.opentakserver_venv
# Enable venv
ENV PATH="/app/.opentakserver_venv/bin:$PATH"

# Install Opentakserver
RUN pip3 install --no-cache-dir opentakserver==${BUILD_VERSION}
# Install Opentakserver, if $BUILD_VERSION is not set, install latest
RUN pip3 install --no-cache-dir opentakserver${BUILD_VERSION:+==$BUILD_VERSION}

# ************************************************************
# Second stage: runtime
Expand All @@ -43,7 +43,7 @@ ENV PATH="/app/.opentakserver_venv/bin:$PATH"
LABEL maintainer="https://github.com/milsimdk"
LABEL org.opencontainers.image.title="Docker image for OpenTAKServer"
LABEL org.opencontainers.image.description="OpenTAKServer is yet another open source TAK Server for ATAK, iTAK, and WinTAK"
LABEL org.opencontainers.image.version="${BUILD_VERSION}"
LABEL org.opencontainers.image.version="${BUILD_VERSION:-latest}"
LABEL org.opencontainers.image.authors="Brian - https://github.com/brian7704"
LABEL org.opencontainers.image.vendor="https://github.com/milsimdk"
LABEL org.opencontainers.image.source="https://github.com/milsimdk/ots-docker-image"
Expand All @@ -63,10 +63,10 @@ COPY --from=builder /app/.opentakserver_venv /app/.opentakserver_venv
RUN pip3 uninstall -y bcrypt && pip3 install bcrypt==4.0.1

# Add Healthcheck for OTS
COPY __init__.py healthcheck.py /app/scripts/
RUN chmod +x /app/scripts/*
COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d
COPY --chmod=755 ./healthcheck.py /app

#HEALTHCHECK --interval=1m --start-period=1m CMD python3 /app/scripts/healthcheck.py
#HEALTHCHECK --interval=1m --start-period=30s CMD /app/healthcheck.py

# Run as OTS user
USER ots
Expand All @@ -84,5 +84,5 @@ EXPOSE 8088/tcp
# 8089 SSL CoT streaming port
EXPOSE 8089/tcp

#ENTRYPOINT [ "python3" ]
CMD [ "python3", "/app/scripts/__init__.py" ]
ENTRYPOINT [ "/etc/entrypoint.d/docker-entrypoint.sh" ]
CMD ["python3", "-m", "opentakserver.app"]
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@

# Docker image for OpenTAKServer
---

# NOT READY FOR PRODUCTION YET
### NOT READY FOR PRODUCTION YET

---

# Docker image for OpenTAKServer

Used here: https://github.com/milsimdk/ots-docker

### Requirements
- Docker must be installed
- Docker compose v2 is used
- Platform support: linux/amd64, linux/arm64

- Source: https://github.com/brian7704/OpenTAKServer
- Platform support: linux/amd64, linux/arm64

### Thanks
- [Brian](https://github.com/brian7704) for creating OpenTAKServer

## Build arguments defaults
### Build arguments defaults
```Dockerfile
ARG OTS_VERSION
ARG BUILD_VERSION
ARG PGID=1000
ARG PUID=1000
```

### Thanks
- [Brian](https://github.com/brian7704) for creating [OpenTAKServer](https://github.com/brian7704/OpenTAKServer)
7 changes: 1 addition & 6 deletions __init__.py → entrypoint.d/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
import os, yaml, subprocess;
import os, yaml;
from opentakserver.defaultconfig import DefaultConfig;
from flask.config import Config as FlaskConfig;

Expand Down Expand Up @@ -61,8 +61,3 @@ def save_config(config):

# Start the OpenTAKServer app
print('Container init | Starting OpenTAKServer...')
try:
ots = subprocess.Popen( ['python3', '-m', 'opentakserver.app'], start_new_session=True )
ots.wait()
except KeyboardInterrupt:
ots.close()
12 changes: 12 additions & 0 deletions entrypoint.d/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e

## Running __init__.py script
if [[ "${@: -1}" = "opentakserver.app" ]]; then
python3 /etc/entrypoint.d/__init__.py
fi

## Running passed command
if [[ "$1" ]]; then
exec "$@"
fi
3 changes: 2 additions & 1 deletion healthcheck.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python3
import requests, sys;

URL = "http://localhost:8081/api/health"

try:
response = requests.head(URL)
except Exception as e:mak
except Exception as e:
sys.exit(1)
else:
if response.status_code == 200:
Expand Down

0 comments on commit bff9f58

Please sign in to comment.