Last active
April 24, 2023 09:58
-
-
Save lucasjellema/5411d40f5948f013a983b8566e829af3 to your computer and use it in GitHub Desktop.
function tweetretriever build specification file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.1 | |
component: build | |
timeoutInSeconds: 6000 | |
runAs: root | |
shell: bash | |
env: | |
# these are local variables to the build config | |
variables: | |
FUNCTION_DIRECTORY: "tweet_retriever_source/functions/tweet-summarizer" | |
# # the value of a vaultVariable is the secret-id (in OCI ID format) stored in the OCI Vault service | |
# you can then access the value of that secret in your build_spec.yaml commands | |
vaultVariables: | |
# exportedVariables are made available to use as parameters in sucessor Build Pipeline stages | |
# For this Build to run, the Build Pipeline needs to have a BUILDRUN_HASH parameter set | |
exportedVariables: | |
- BUILDRUN_HASH | |
steps: | |
- type: Command | |
name: "Export variables" | |
timeoutInSeconds: 40 | |
command: | | |
export BUILDRUN_HASH=`echo ${OCI_BUILD_RUN_ID} | rev | cut -c 1-7` | |
echo "BUILDRUN_HASH: " $BUILDRUN_HASH | |
echo "FUNCTION-DIRECTORY: " $FUNCTION_DIRECTORY | |
onFailure: | |
- type: Command | |
timeoutInSeconds: 40 | |
command: | | |
echo "Handling Failure" | |
echo "Failure successfully handled" | |
timeoutInSeconds: 400 | |
runAs: root | |
- type: Command | |
timeoutInSeconds: 600 | |
name: "Install Prereqs" | |
command: | | |
cd ${OCI_WORKSPACE_DIR}/${FUNCTION_DIRECTORY} | |
echo go install NVM | |
pwd | |
# install nvm | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
nvm install lts/erbium | |
echo "NODE VERSION: $(node -v)" | |
echo "NPM VERSION: $(npm -v)" | |
onFailure: | |
- type: Command | |
command: | | |
echo "Handling Failure" | |
echo "Failure successfully handled" | |
timeoutInSeconds: 40 | |
runAs: root | |
- type: Command | |
timeoutInSeconds: 600 | |
name: "NPM install" | |
command: | | |
cd ${OCI_WORKSPACE_DIR}/${FUNCTION_DIRECTORY} | |
npm install | |
onFailure: | |
- type: Command | |
command: | | |
echo "Handling Failure" | |
echo "Failure successfully handled" | |
timeoutInSeconds: 40 | |
runAs: root | |
- type: Command | |
timeoutInSeconds: 1200 | |
name: "Build Function into container image" | |
command: | | |
cd ${OCI_WORKSPACE_DIR}/${FUNCTION_DIRECTORY} | |
fn build --verbose | |
image=$(docker images | grep tweet_retriever | awk -F ' ' '{print $3}') ; docker tag $image tweet_retriever_function_image | |
onFailure: | |
- type: Command | |
command: | | |
echo "Handling Failure" | |
echo "Failure successfully handled" | |
timeoutInSeconds: 40 | |
runAs: root | |
outputArtifacts: | |
- name: output01 | |
type: DOCKER_IMAGE | |
# this location tag doesn't effect the tag used to deliver the container image | |
# to the Container Registry | |
location: tweet_retriever_function_image:latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment