From 423a7875218cb4fee4034c810c48ee8953d501cf Mon Sep 17 00:00:00 2001 From: Luca Cireddu Date: Mon, 22 Aug 2022 14:14:45 +0200 Subject: [PATCH 1/2] Adds dockerignore file --- .dockerignore | 291 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..44f038d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,291 @@ +.vscode +*.code-workspace +.history/ +.idea +cmake-build-*/ +*.iml +*.iws +out/ +.idea_modules/ +atlassian-ide-plugin.xml +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +.Python +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +.venv +pip-selfcheck.json +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates +*.userprefs +mono_crash.* +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ +.vs/ +Generated\ Files/ +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* +*.VisualState.xml +TestResult.xml +nunit-*.xml +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c +BenchmarkDotNet.Artifacts/ +project.lock.json +project.fragment.lock.json +artifacts/ +ScaffoldingReadMe.txt +StyleCopReport.xml +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc +_Chutzpah* +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb +*.psess +*.vsp +*.vspx +*.sap +*.e2e +$tf/ +*.gpState +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user +_TeamCity* +*.dotCover +.axoCover/* +!.axoCover/settings.json +coverage*.json +coverage*.xml +coverage*.info +*.coverage +*.coveragexml +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* +*.mm.* +AutoTest.Net/ +.sass-cache/ +[Ee]xpress/ +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html +publish/ +*.[Pp]ublish.xml +*.azurePubxml +*.pubxml +*.publishproj +PublishScripts/ +*.nupkg +*.snupkg +**/[Pp]ackages/* +!**/[Pp]ackages/build/ +*.nuget.props +*.nuget.targets +csx/ +*.build.csdef +ecf/ +rcf/ +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload +*.[Cc]ache +!?*.[Cc]ache/ +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs +Generated_Code/ +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak +*.mdf +*.ldf +*.ndf +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl +FakesAssemblies/ +*.GhostDoc.xml +.ntvs_analysis.dat +node_modules/ +*.plg +*.opt +*.vbw +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions +.paket/paket.exe +paket-files/ +.fake/ +.cr/personal +__pycache__/ +*.pyc +*.tss +*.jmconfig +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs +OpenCover/ +ASALocalRun/ +*.binlog +*.nvuser +.mfractor/ +.localhistory/ +healthchecksdb +MigrationBackup/ +.ionide/ +FodyWeavers.xsd +*.py[cod] +*$py.class +*.so +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST +*.manifest +*.spec +pip-log.txt +pip-delete-this-directory.txt +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ +*.mo +*.pot +local_settings.py +db.sqlite3 +db.sqlite3-journal +instance/ +.webassets-cache +.scrapy +docs/_build/ +.pybuilder/ +target/ +.ipynb_checkpoints +profile_default/ +ipython_config.py +__pypackages__/ +celerybeat-schedule +celerybeat.pid +*.sage.py +.env +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +.spyderproject +.spyproject +.ropeproject +/site +.mypy_cache/ +.dmypy.json +dmypy.json +.pyre/ +.pytype/ +cython_debug/ +.github +.travis.yml \ No newline at end of file From 3373fdca03c5b696e7c7b658b02f842cfe8eb9ab Mon Sep 17 00:00:00 2001 From: Luca Cireddu Date: Mon, 22 Aug 2022 15:58:02 +0200 Subject: [PATCH 2/2] Adds Dockerfile --- Dockerfile | 19 +++++++++++++++++++ docker/run.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 Dockerfile create mode 100644 docker/run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a339f40 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.10-alpine AS os + +FROM os AS venv +COPY requirements.txt / +RUN python3 -m venv /venv \ + && /venv/bin/pip3 install --upgrade pip setuptools \ + && /venv/bin/pip3 install -r /requirements.txt + +FROM os AS prod +COPY --from=venv /venv /venv +COPY aprs2influxdb /app +COPY docker/run.sh / +RUN addgroup -g 1000 aprs2influxdb \ + && adduser -h /home/aprs2influxdb -s /bin/sh -S -D -u 1000 aprs2influxdb \ + && mkdir -p /home/aprs2influxdb \ + && chown 1000:1000 /home/aprs2influxdb +WORKDIR /home/aprs2influxdb +USER 1000:1000 +ENTRYPOINT ["/bin/sh", "/run.sh"] \ No newline at end of file diff --git a/docker/run.sh b/docker/run.sh new file mode 100644 index 0000000..45f38ab --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +if [ -z "${INFLUXDB_HOST}" ]; then + INFLUXDB_HOST="influxdb" +fi + +if [ -z "${INFLUXDB_PORT}" ]; then + INFLUXDB_PORT="8086" +fi + +if [ -z "${INFLUXDB_USER}" ]; then + INFLUXDB_USER="aprs2influxdb" +fi + +if [ -z "${INFLUXDB_PASSWORD}" ]; then + INFLUXDB_PASSWORD="aprs2influxdb" +fi + +if [ -z "${INFLUXDB_NAME}" ]; then + INFLUXDB_NAME="aprs2influxdb" +fi + +if [ -z "${CALLSIGN}" ]; then + echo "Invalid callsign: \"${CALLSIGN}\"" + exit 1 +fi + +if [ -z "${PORT}" ]; then + PORT="10152" +fi + +if [ -z "${INTERVAL}" ]; then + INTERVAL="15" +fi + +APRS2INFLUXDB_CMD_DEBUG="" +if [ "${DEBUG}" = "true" ]; then + APRS2INFLUXDB_CMD_DEBUG="--debug" +fi + +/venv/bin/python3 \ + /app/__main__.py \ + --dbhost="${INFLUXDB_HOST}" \ + --dbport="${INFLUXDB_PORT}" \ + --dbuser="${INFLUXDB_USER}" \ + --dbpassword="${INFLUXDB_PASSWORD}" \ + --dbname="${INFLUXDB_NAME}" \ + --callsign="${CALLSIGN}" \ + --port="${PORT}" \ + --interval="${INTERVAL}" \ + ${APRS2INFLUXDB_CMD_DEBUG}