Skip to content

Commit

Permalink
update: apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
thepsalmist committed Apr 4, 2024
1 parent 3ad061e commit d69225e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- '**'
env:
IMAGE_NAME: "mcsystems/news-search-api"
BETA_VERSION: "b1"

jobs:

Expand All @@ -32,22 +33,25 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Determine Tag
id: tag
run: |
if [ "${{ github.ref_type }}" = "tag" ] && [ "${{ github.ref }}" != "refs/heads/staging" ]; then
echo "tag_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "tag_name=staging" >> $GITHUB_OUTPUT
fi
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha
type=raw,value=staging-${{ env.BETA_VERSION }},enable=${{ endsWith(github.ref, 'staging') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag_name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
#registry defaults to dockerhub
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
24 changes: 13 additions & 11 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,26 @@ TERMAGGRS="top,significant,rare"
APP_NAME="news-search-api"

# Check if running as root
if [[ $UID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
is_root() {
if [ $(whoami) != "root" ]; then
echo "This script must be run as root."
exit 1
fi
}

is_root
echo "Running as root"

LOGIN_USER=$(whoami)
LOGIN_USER=$(who am i | awk '{ print $1 }')
if [ "x$LOGIN_USER" = x ]; then
# XXX fall back to whoami (look by uid)
echo could not find login user 1>&2
exit 1
fi

run_as_login_user() {
if [ $(whoami) = root ]; then
is_root
su $LOGIN_USER -c "$*"
else
$*
fi
}

help()
Expand Down Expand Up @@ -75,7 +77,7 @@ rm -rf "$PRIVATE_CONF_DIR"
mkdir -p "$PRIVATE_CONF_DIR"
chmod go-rwx "$PRIVATE_CONF_DIR"
CONFIG_REPO_PREFIX=$(zzz [email protected]:zrqvnpybhq)
CONFIG_REPO_NAME=$(zzz fgbel-vaqrkre-pbasvt)
CONFIG_REPO_NAME=$(zzz arjf-frnepu-ncv-pbasvt)
echo cloning $CONFIG_REPO_NAME repo 1>&2
if ! run_as_login_user "git clone $CONFIG_REPO_PREFIX/$CONFIG_REPO_NAME.git" >/dev/null 2>&1; then
echo "FATAL: could not clone config repo" 1>&2
Expand All @@ -100,7 +102,7 @@ GH_REPO_PREFIX="https://github.com/mediacloud"
GH_REPO_NAME="news-search-api"
DOCKER_COMPOSE_FILE="docker-compose.yml"
echo "Fetching $DOCKER_COMPOSE_FILE from $GH_REPO_NAME repo..."
if ! curl -sSfL "$GH_REPO_PREFIX/$GH_REPO_NAME/raw/main/$DOCKER_COMPOSE_FILE" -o "$INSTALL_DIR/$DOCKER_COMPOSE_FILE"; then
if ! curl -sSfL "$GH_REPO_PREFIX/$GH_REPO_NAME/raw/$IMAGE_TAG/$DOCKER_COMPOSE_FILE" -o "$INSTALL_DIR/$DOCKER_COMPOSE_FILE"; then
echo "FATAL: Could not fetch $DOCKER_COMPOSE_FILE from config repo"
exit 1

Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
ports:
- 8000:8000
networks:
- story-indexer
- new-search-api
volumes:
- .:/app

Expand All @@ -15,15 +15,15 @@ services:
environment:
APIURL: http://api:8000/v1
ports:
- 8001:8501
- 8501:8501
networks:
- story-indexer
- new-search-api
volumes:
- .:/app
depends_on:
- api
command: streamlit run ui.py

networks:
story-indexer:
name: story-indexer
new-search-api:
name: new-search-api

0 comments on commit d69225e

Please sign in to comment.