Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Improved scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckierDodge committed Dec 14, 2023
1 parent 745cd22 commit 4b2e001
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 30 deletions.
19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
FROM python:3.11
FROM ghcr.io/ad-sdl/wei

RUN mkdir -p /webcam_module
LABEL org.opencontainers.image.source=https://github.com/AD-SDL/webcam_module
LABEL org.opencontainers.image.description="An example module that implements a simple webcam snapshot action"
LABEL org.opencontainers.image.licenses=MIT

COPY ./src /webcam_module/src
COPY ./README.md /webcam_module/README.md
COPY ./pyproject.toml /webcam_module/pyproject.toml
USER wei
WORKDIR /home/wei

RUN mkdir -p webcam_module

COPY --chown=wei:wei ./src webcam_module/src
COPY --chown=wei:wei ./README.md webcam_module/README.md
COPY --chown=wei:wei ./pyproject.toml webcam_module/pyproject.toml

RUN pip install ./webcam_module

CMD ["python", "/webcam_module/src/webcam_rest_node.py"]
CMD ["python", "webcam_module/src/webcam_rest_node.py"]
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.0"
name: webcam_module
services:
webcam_node:
image: webcam_module
image: ghcr.io/ad-sdl/webcam_module
build:
context: .
dockerfile: Dockerfile
Expand Down
14 changes: 6 additions & 8 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/bin/bash
#!/usr/bin/env bash

SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
source "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/script_helper.sh

version=`$SCRIPTPATH/version.sh`
name=`$SCRIPTPATH/name.sh`

cd $SCRIPTPATH/..
cd $project_path

docker build \
-t ghcr.io/ad-sdl/${name}:${version} \
-t ghcr.io/ad-sdl/${name}:dev \
-t ghcr.io/ad-sdl/${project_name}:${project_version} \
-t ghcr.io/ad-sdl/${project_name}:dev \
-t ghcr.io/ad-sdl/${project_name}:latest \
.
6 changes: 6 additions & 0 deletions scripts/logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

source "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/script_helper.sh
cd $project_path

docker compose logs "$@"
5 changes: 0 additions & 5 deletions scripts/name.sh

This file was deleted.

9 changes: 4 additions & 5 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash

SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
source "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/script_helper.sh

version=`$SCRIPTPATH/version.sh`
name=`$SCRIPTPATH/name.sh`
$scripts_path/build.sh

docker push ghcr.io/ad-sdl/${name}:${version}
docker push ghcr.io/ad-sdl/${project_name}:${project_version}
6 changes: 6 additions & 0 deletions scripts/restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

source "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/script_helper.sh
cd $project_path

docker compose restart
19 changes: 19 additions & 0 deletions scripts/script_helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Invoke this helper from other scripts in the scripts dir of a project with:
# source "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/script_helper.sh

USER_ID=$(id -u)
GROUP_ID=$(id -g)

scripts_path="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd $scripts_path
project_path=`git rev-parse --show-toplevel`
if [[ -f ${project_path}/pyproject.toml ]]; then
project_name=`grep -oP '(?<=name = ")[^"]+' $project_path/pyproject.toml | head -n 1`
project_version=`grep -oP '(?<=version = ")[^"]+' $project_path/pyproject.toml | head -n 1`
else
project_name=`basename $project_path`
project_version="0.0.0"
fi

6 changes: 6 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

source "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/script_helper.sh
cd $project_path

docker compose up "$@"
6 changes: 6 additions & 0 deletions scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

source "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/script_helper.sh
cd $project_path

docker compose down
5 changes: 0 additions & 5 deletions scripts/version.sh

This file was deleted.

0 comments on commit 4b2e001

Please sign in to comment.