<commit_before>#!/bin/bash

# NOTE: this script is expectd to be run from project checkout dir

set -eu
: ${TARGET_ENV:?}
: ${TARGET_ENV_PORT:?}
set -x

VERSION=`cat version`
AWS_TEST=ubuntu@172.16.58.3
IDENTITY_FILE=/var/go/hsl-liipi.pem

DOCKER_REGISTRY="172.31.0.27:5000"
LOCAL_IMAGE="parkandrideapi/server:$TARGET_ENV"
REGISTRY_IMAGE="$DOCKER_REGISTRY/$LOCAL_IMAGE"
CONTAINER_NAME="parkandrideapi-server-$TARGET_ENV"
DOCKERFILE_DIR="etc/docker/app"
APP_LATEST="parkandride-application-latest.jar"
APP_NEW="parkandride-application-$VERSION.jar"

function build_image() {
  cp staging/fi/hsl/parkandride/parkandride-application/$VERSION/$APP_NEW $DOCKERFILE_DIR/$APP_LATEST
  cd $DOCKERFILE_DIR
  docker build -t $LOCAL_IMAGE .
}

function push_image() {
  docker tag $LOCAL_IMAGE $REGISTRY_IMAGE
  docker push $REGISTRY_IMAGE
}

function restart_container() {
  ssh -i $IDENTITY_FILE -oStrictHostKeyChecking=no $AWS_TEST "docker stop $CONTAINER_NAME"
  ssh -i $IDENTITY_FILE $AWS_TEST "docker rm $CONTAINER_NAME"
  ssh -i $IDENTITY_FILE $AWS_TEST "docker run -d -p $TARGET_ENV_PORT:8080 --name $CONTAINER_NAME $REGISTRY_IMAGE"
}

build_image
push_image
restart_container<commit_msg>chore(awsDevSubnet): pull updated image before restart<commit_after>#!/bin/bash

# NOTE: this script is expectd to be run from project checkout dir

set -eu
: ${TARGET_ENV:?}
: ${TARGET_ENV_PORT:?}
set -x

VERSION=`cat version`
AWS_TEST=ubuntu@172.16.58.3
IDENTITY_FILE=/var/go/hsl-liipi.pem

DOCKER_REGISTRY="172.31.0.27:5000"
LOCAL_IMAGE="parkandrideapi/server:$TARGET_ENV"
REGISTRY_IMAGE="$DOCKER_REGISTRY/$LOCAL_IMAGE"
CONTAINER_NAME="parkandrideapi-server-$TARGET_ENV"
DOCKERFILE_DIR="etc/docker/app"
APP_LATEST="parkandride-application-latest.jar"
APP_NEW="parkandride-application-$VERSION.jar"

function build_image() {
  cp staging/fi/hsl/parkandride/parkandride-application/$VERSION/$APP_NEW $DOCKERFILE_DIR/$APP_LATEST
  cd $DOCKERFILE_DIR
  docker build -t $LOCAL_IMAGE .
}

function push_image() {
  docker tag $LOCAL_IMAGE $REGISTRY_IMAGE
  docker push $REGISTRY_IMAGE
}

function restart_container() {
  ssh -i $IDENTITY_FILE -oStrictHostKeyChecking=no $AWS_TEST "docker stop $CONTAINER_NAME"
  ssh -i $IDENTITY_FILE $AWS_TEST "docker rm $CONTAINER_NAME"
  ssh -i $IDENTITY_FILE $AWS_TEST "docker pull $REGISTRY_IMAGE"
  ssh -i $IDENTITY_FILE $AWS_TEST "docker run -d -p $TARGET_ENV_PORT:8080 --name $CONTAINER_NAME $REGISTRY_IMAGE"
}

build_image
push_image
restart_container
{'fraction_non_alphanumeric': 0.11515151515151516, 'fraction_numerical': 0.019393939393939394, 'mean_word_length': 6.369047619047619, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2463054', 'n_tokens_mistral': 1029, 'n_tokens_neox': 939, 'n_words': 175}