From 1eb58280a57f87a94b0e7318734b5087dbd6d48e Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Sun, 29 Dec 2019 14:24:26 -0800 Subject: [PATCH] Container progress --- .gitignore | 1 + .gitlab-ci.yml | 17 ++++------------- context/Dockerfile | 5 +++-- context/entrypoint | 19 +++++++++++++++++++ docker-compose.yml | 21 +++++---------------- 5 files changed, 32 insertions(+), 31 deletions(-) create mode 100755 context/entrypoint diff --git a/.gitignore b/.gitignore index 89a377c..8c723db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea *.iml config/*.conf +config/*.users diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e8c28e2..c7bb40d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,8 +25,7 @@ lint:shell-script: before_script: - shellcheck -V script: -# - shellcheck ./context/s3-purge.sh - - exit 0 + - shellcheck ./context/entrypoint # # IMAGE BUILDS/PUSHES @@ -41,18 +40,10 @@ build:master: - master when: manual -build:dev-amd64: +build:dev: stage: deploy script: - - docker build --build-arg opts="CGO_ENABLED=0 GOARCH=amd64" --pull -t "$CI_REGISTRY_IMAGE:dev-amd64" ./context/ -# - docker push "$CI_REGISTRY_IMAGE:dev-amd64" - except: - - master - -build:dev-arm7: - stage: deploy - script: - - docker build --build-arg opts="GOARCH=arm GOARM=7" --pull -t "$CI_REGISTRY_IMAGE:dev-arm7" ./context/ - # - docker push "$CI_REGISTRY_IMAGE:dev-arm7" + - docker build --pull -t "$CI_REGISTRY_IMAGE:dev" ./context/ +# - docker push "$CI_REGISTRY_IMAGE:dev" except: - master diff --git a/context/Dockerfile b/context/Dockerfile index 9091a3e..221b3cc 100644 --- a/context/Dockerfile +++ b/context/Dockerfile @@ -12,6 +12,7 @@ RUN apt-get update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -# TODO: entrypoint? - EXPOSE 3493 + +COPY entrypoint /usr/local/bin/ +ENTRYPOINT ["entrypoint"] diff --git a/context/entrypoint b/context/entrypoint new file mode 100755 index 0000000..75947d1 --- /dev/null +++ b/context/entrypoint @@ -0,0 +1,19 @@ +#!/bin/bash + +CONFIG_SOURCE="/opt/nut-config" +export CONFIG_SOURCE + +CONFIG_DEST="/etc/nut" +export CONFIG_DEST + +echo "Copying configurations from ${CONFIG_SOURCE} to ${CONFIG_DEST}..." + +find $CONFIG_SOURCE -name "*.conf" -exec cp '{}' $CONFIG_DEST \; + +echo "Restarting services..." + +upsdrvctl start +/etc/init.d/nut-server restart + +echo "Ready on port 3493" +tail -F /dev/null diff --git a/docker-compose.yml b/docker-compose.yml index a32bbfb..ec0ea1d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,22 +1,11 @@ version: "3.7" services: nut: - #image: containers.ethitter.com:443/docker/s3-object-expirer:latest + image: nut-upsd:latest build: context: ./context + ports: + - 3493:3493 restart: unless-stopped - # TODO: mount a dir -# secrets: -# - source: s3_config -# target: /s3_config -# - source: s3_bucket -# target: /s3_bucket -# - source: s3_expire_days -# target: /s3_expire_days -#secrets: -# s3_config: -# file: ./config/.s3cfg -# s3_bucket: -# file: ./config/bucket -# s3_expire_days: -# file: ./config/expire_age_days + volumes: + - ./config/:/opt/nut-config -- GitLab