Skip to content

Commit

Permalink
initial wip for unifios
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonEverling committed Feb 8, 2024
0 parents commit 397be65
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set line endings to LF for scripts
* text eol=lf
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Docker CI
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Docker
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_TOKEN
- name: Build 22.04
run: |
UNIFI_VERSION=$(wget --quiet --no-cookies https://dl.ui.com/unifi/debian/dists/stable/ubiquiti/binary-amd64/Packages -O - | sed -n 's/Version: //p')
docker build . --pull --build-arg OCIE_VERSION=22.04 UNIFI_VERSION=$UNIFI_VERSION --tag bshp/unifi:latest --no-cache
- name: Push 22.04
run: |
docker tag bshp/unifi:latest bshp/unifi:$UNIFI_VERSION
docker push bshp/unifi:latest
docker push bshp/unifi:$UNIFI_VERSION
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.log
.build
*.tar
*.tar.gz
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Ocie Version, e.g 22.04 unquoted
ARG OCIE_VERSION

ARG UNIFI_VERSION=""

FROM bshp/ocie:${OCIE_VERSION}

ARG UNIFI_VERSION

# Ocie
ENV OCIE_CONFIG=/etc/unifi \
APP_GROUP="root" \
APP_OWNER="root" \
APP_DATA=/opt/data \
APP_HOME=/usr/lib/unifi \
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 \
UNIFI_VERSION=${UNIFI_VERSION}

RUN <<"EOD" bash
set -eux;
# Source environment for OS_CODENAME
. /etc/environment;
# Add MongoDB Repo
wget --quiet "https://www.mongodb.org/static/pgp/server-7.0.asc" -O- | gpg --dearmor -o /usr/share/keyrings/mongodb.gpg;
echo "deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb.gpg] https://repo.mongodb.org/apt/ubuntu ${OS_CODENAME}/mongodb-org/7.0 multiverse" \
| tee /etc/apt/sources.list.d/mongodb-org-7.0.list;
# Setup system
ocie --pkg "-add binutils,mongodb-org,libcap2,logrotate,openjdk-17-jre-headless";
if [[ -z "${UNIFI_VERSION}" ]];then
UNIFI_VERSION=$(wget --quiet --no-cookies https://dl.ui.com/unifi/debian/dists/stable/ubiquiti/binary-amd64/Packages -O - | sed -n 's/Version: //p');
fi;
wget --quiet --no-cookies https://dl.ui.com/unifi/${UNIFI_VERSION%%-*}/UniFi.unix.zip -O /tmp/unifi.zip;
unzip -qq /tmp/unifi.zip -d /usr/lib/ && mv /usr/lib/UniFi ${APP_HOME};
install -d -m 0755 -o root -g root ${APP_DATA};
ln -s ${APP_DATA} ${APP_HOME}/;
# Cleanup image, remove unused directories and files, etc..
ocie --clean "-base -path /tmp/ -pattern '*.zip'";
EOD

COPY --chown=root:root --chmod=0755 ./src/ ./

ENTRYPOINT ["/usr/sbin/ociectl", "--run"]
37 changes: 37 additions & 0 deletions src/etc/unifi/config.ocie
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

APP_VOLS="/opt/data";

function app_shutdown()
{
/usr/bin/java -jar ${APP_HOME}/lib/ace.jar stop
}

function app_reload()
{
app_shutdown;
app_start;
}

function app_start()
{
/usr/bin/java -Dlog4j2.formatMsgNoLookups=true \
-Dunifi.datadir=/opt/data \
-Dfile.encoding=UTF-8 \
-Djava.awt.headless=true \
-Dapple.awt.UIElement=true \
-XX:+UseParallelGC \
-XX:+ExitOnOutOfMemoryError \
-XX:+CrashOnOutOfMemoryError \
--add-opens java.base/java.lang=ALL-UNNAMED \
--add-opens java.base/java.time=ALL-UNNAMED \
--add-opens java.base/sun.security.util=ALL-UNNAMED \
--add-opens java.base/java.io=ALL-UNNAMED \
--add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED \
-jar ${APP_HOME}/lib/ace.jar start
}

function app_certs()
{
${OCIE_LIB}/cacerts;
}

0 comments on commit 397be65

Please sign in to comment.