vania-janet/multiturn-rag-retrieval-data huggingface dataset:
Getting started with Swift 

IBM® Cloud Foundry is deprecated and no longer supported as of 1 June 2023. For more information, see the [deprecation details](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-deprecationdep_details).

Note the [Swift buildpack is deprecated](http://ibm.biz/cf-buildpack-swift-deprecation).

Congratulations, you deployed a Hello World sample app on IBM Cloud®! To get started, follow this step-by-step guide. Or, [download the sample code](https://github.com/IBM-Cloud/get-started-swift) and explore on your own.

By following this tutorial, you'll set up a development environment, deploy an app locally on IBM Cloud®, and integrate an IBM Cloud database service in your app.

Throughout these docs, references to the Cloud Foundry CLI are now updated to the IBM Cloud CLI! The IBM Cloud CLI has the same familiar Cloud Foundry commands, but with better integration with IBM Cloud accounts and other services. Learn more about getting started with the IBM Cloud CLI in this tutorial.



 Before you begin 



* [Git](https://git-scm.com/downloads)
* [IBM Cloud CLI](https://cloud.ibm.com/docs/cli?topic=cli-install-ibmcloud-cli)
* [Swift compiler](https://swift.org/download/) for your platform.







 Step 1: Clone the sample app 

First, clone the repository and change to the directory to where the sample app is located.

git clone https://github.com/IBM-Cloud/get-started-swift

cd get-started-swift

Peruse the files in the get-started-swift directory to familiarize yourself with the contents.





 Step 2: Run the app locally 

Once you have installed the Swift compiler and cloned this Git repository, you can now compile and run the app.



1.
npm install --save fabric-contract-api@latest-1.4 fabric-shim@latest-1.4

Go

Because Fabric v2.x peers do not have a "shim" (the external dependencies that allowed smart contracts to run on earlier versions of Fabric), you need to vendor the shim and then repackage any smart contracts written in Golang (Go) that use the [Go SDK](https://github.com/hyperledger/fabric-sdk-go). "Vendoring the shim" effectively means that you are copying the dependencies into your project. Without this vendoring and repackaging, the Go smart contract cannot run on a peer using a Fabric 2.x image. If you are using the [IBM Developer Tools](https://cloud.ibm.com/docs/blockchain?topic=blockchain-develop-vscode) to develop and package your smart contract, the tooling performs the vendoring for you. This process is not required for smart contracts that are written in Java or Node.js, nor for Go smart contracts that use the [Go contract-api](https://github.com/hyperledger/fabric-contract-api-go).

Java
The build.gradle file for the smart contract must be updated:



1. If the smart contract uses the shadowjar 2.x plugin, then it should be updated to version 5 by using the following code:

plugins {
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'java'
}
2. The repositories section of the file must contain the maven URL for jitpack, for example:

repositories {
...
maven {
url 'https://jitpack.io'
}
}



Init functions

If the smart contract was written using the low-level APIs provided by the Fabric Chaincode Shim API, your smart contract needs to contain an Init function that is used to initialize the chaincode.
npm install ibmcloud-appid-js
* To add the CDN, add the following link to your main HTML file.

<script src="https://cdn.appid.cloud.ibm.com/appid-0.3.0.min.js"></script>



3. Add your client ID and discovery endpoint to your app to initialize the SDK.

const appID = new AppID();
await appID.init({
clientId: '<spaClientID>',
discoveryEndpoint: '<wellKnownEndpoint>'
});
4. In your application code, after your login button configuration, add a call to signin. A pop-up window opens where a user is prompted to enter their credentials. After a successful authentication, the screen closes and they are authenticated.

const tokens = await appID.signin();







 Configuring silent login 

When [SSO for Cloud Directory](https://cloud.ibm.com/docs/appid?topic=appid-cd-ssocd-sso) is enabled, you can automatically obtain new tokens for a user without them having to reauthenticate by using silent login. To enable silent login, use the following steps as a guide.

Refresh tokens are not returned in the SPA flow.



1. In the App ID dashboard, navigate to Cloud Directory > Single Sign-on.
2. Toggle Enable single sign-on to Enabled.
3. Click Save.
4. Add the following code to your application. Be sure to configure your application to show the login button if silent login fails.

const tokens = await appID.silentSignin();
if (!tokens) {
document.getElementById('login').addEventListener('click', async () => {
const tokens = await appID.signin();
});
}
* [Installing from the Cloud Functions console](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-pkg_text_to_speechtexttospeech_ui)
* [Using the Text to Speech package](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-pkg_text_to_speechusage_texttospeech)



[Discovery](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-pkg_discoverypkg_discovery)



* [Creating a Discovery service instance](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-pkg_discoveryservice_instance_discovery)
* [Installing the Discovery package](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-pkg_discoveryinstall_discovery)



* [Installing from the Cloud Functions CLI](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-pkg_discoverydiscovery_cli)
* [Installing from the Cloud Functions console](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-pkg_discoverydiscovery_ui)



* [Using the Discovery package](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-pkg_discoveryusage_discovery)









 Setting up an automated tool chain 

[Deploying entities with a manifest file](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-deploydeploy)



* [Creating the Hello World API example](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-deploydeploy_helloworld_example)
Setting up the IBM Cloud Schematics API 

Before you begin using the IBM Cloud® Schematics API to deploy IBM Spectrum Scale, review and complete the following prerequisites:



1.  Make sure that you have access to an IBM Cloud account and that you generated an IBM Cloud API key to authenticate to IBM Cloud.
2.  If the GitHub repository that hosts the Terraform code is not public, generate a [personal GitHub access token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) for authentication. If you are using the [public IBM GitHub repository](https://github.com/IBM/ibm-spectrum-scale-ibm-cloud-schematics), you do not need to complete this task.
3.  Install the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli?topic=cli-install-ibmcloud-cli) and login to the IBM Cloud account through the IBM Cloud CLI.
4.  Install Python 3 or a newer version.
5.  Follow the [IBM Cloud Schematics SDK for Python instructions](https://cloud.ibm.com/apidocs/schematics?code=pythonintroduction) to set up and install the IBM Cloud Schematics API by using pip.
6.  Install all of the respective Python application dependencies that your Python code will be using, such as logging, os, yaml, and json, which are required when you use pip3 to run the application.





  Next steps 

After you've reviewed and completed the prerequisites for setting up the API, you are ready to [Create a workspace](https://cloud.ibm.com/docs/hpc-spectrum-scale?topic=hpc-spectrum-scale-creating-workspace&interface=api).
For instructions to configure the build job, see the [Configuring a Nexus npm build job in your pipeline](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-nexusconfig_nexus_npm) section.
11. Optional: If you are using a toolchain on IBM Cloud Public and you want to build your app by using Nexus with Maven, configure your pipeline to add a Maven build job. For instructions to configure the build job, see the [Configuring a Nexus Maven build job in your pipeline](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-nexusconfig_nexus_maven) section.





 Configuring a Nexus npm build job in your pipeline 

Before you configure an npm build job in your pipeline, you need a working pipeline that can use your build SCM repo as input, and you must configure Nexus for your toolchain. For instructions to configure Nexus, see the [Nexus](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-nexusnexus) section.

Configure the Delivery Pipeline to add an npm build job:



1. Create a stage and set the input to the appropriate SCM repo.
2. On the stage, add a build job.
3. Configure the build job:

Zoom

![npm build job](https://cloud.ibm.com/docs-content/v1/content/562806c0b18119f4d21cb66f5ae6d051634b4a16/ContinuousDelivery/images/nexus_npm_job.png)

Figure 1. npm build job

a. For the builder type, select npm (Artifactory or Nexus).

b.
See [GSKit V8 - Install, Uninstall and Upgrade instructions](http://www.ibm.com/support/docview.wss?uid=swg21631462). Click the operating system tab that applies to your client machine’s operating system. If you are installing the GSKit on a Windows computer, ensure that you specify the GSKit installation directory path (<installation_directory>gsk8bin) for the PATH environment variable.

Before attempting to connect to your Db2 on Cloud database, verify that you have the [prerequisites](https://cloud.ibm.com/docs/Db2onCloud/connecting?topic=Db2onCloud-connect_ovprereqs).

If you intend to connect by using the SSL protocol, download the DigiCertGlobalRootCA.crt SSL certificate from the web console to a directory on the client machine. To download the certificate, click Connection > Connection Information and then click the Connection with SSL tab.





 Procedure 



1. Choose one of the following approaches to make your connection:



* To create a connection with SSL, complete the following steps:

a. Issue the following command:

cd /<ssl_directory_name>/ssl

where /<ssl_directory_name>/ssl is the path to the directory into which you downloaded the DigiCertGlobalRootCA.crt SSL certificate.

b. Create a client key database and a stash file by using the GSKCapiCmd tool. For example, the following command creates a client key database that is called dashclient.kdb and a stash file that is called dashclient.sth:

gsk8capicmd_64 -keydb -create -db "dashclient.kdb" -pw "passw0rdpw0" -stash

where passw0rdpw0 is a password. The -stash option creates a stash file in the same path as that of the client key database, with a file extension of .sth.
Deploying your application code from a local source 

Let's deploy a simple hello world app to see how Code Engine works. Follow the steps to create a project, prepare your code, and deploy your app.

Review [Cloud Foundry and Code Engine terms](https://cloud.ibm.com/docs/codeengine?topic=codeengine-migrate-cf-ce-terms) before starting this tutorial.



 Objectives 



* Learn the similarities between Code Engine and Cloud Foundry.
* Learn the general process of deploying apps in Code Engine.
* Deploy an application from code on your local system with Code Engine.







 Prerequisites 

Before you can get started with Code Engine, you need to set up your account and install the CLI.



* All Code Engine users are required to have a Pay-as-you-Go account.
* While you can use Code Engine through the console, the examples in this documentation focus on the command line. Therefore, you must install the Code Engine CLI.

ibmcloud plugin install code-engine

For more information, see [setting up the Code Engine CLI](https://cloud.ibm.com/docs/codeengine?topic=codeengine-install-cli). For more information about the CLI, see [Code Engine CLI reference](https://cloud.ibm.com/docs/codeengine?topic=codeengine-cli).



All Code Engine users are required to have a Pay-as-you-Go account. Tutorials might incur costs. Use the Cost Estimator to generate a cost estimate based on your projected usage. For more information, see [Code Engine pricing](https://cloud.ibm.com/docs/codeengine?topic=codeengine-pricing).





 Step 1: Log in to IBM Cloud 

Follow these steps to log in to your IBM Cloud account and target a resource group.



1. Log in to the IBM Cloud CLI.

ibmcloud login
2. Target a resource group by running the following command. To get a list of your resource groups, run ibmcloud resource groups.
Configuring Nexus 

Configure the Nexus Repository Manager to store build artifacts in your Nexus repository (repo).



1. If you are configuring this tool integration as you are creating the toolchain, in the Configurable Integrations section, click Nexus.
2. If you have a toolchain and are adding this tool integration to it, from the IBM Cloud console, click the menu icon ![hamburger icon](https://cloud.ibm.com/docs-content/v1/content/562806c0b18119f4d21cb66f5ae6d051634b4a16/ContinuousDelivery/images/icon_hamburger.svg) and select DevOps. On the Toolchains page, click the toolchain to open its Overview page. Alternatively, on your app's Overview page, on the Continuous delivery card, click View toolchain. Then, click Overview.

a. Click Add tool.

b. In the Tool Integrations section, click Nexus.
3. Type a name for this instance of the Nexus tool integration.
4. Type the URL for the Nexus repo that you want to open when you click the Nexus card from your toolchain.
5. Select the repository type that you want to connect to.
6. If you selected npm registry, follow these steps:

a. Type the email address that is associated with your registry.

b. Type the authentication token that is associated with your registry.

c. Type the URL for your Nexus release repo, which is your private registry on the Nexus server.

d. Type the URL for the Mirror or Public registry that you use to combine multiple public and private npm registries. For example, this URL might be the URL of the virtual registry on your Nexus server that can access both your private registry and a cache of the npm global registry.
7. If you selected Maven repository, follow these steps:

a. Type the user ID that is associated with your repo.

b.
Setting up the IBM Cloud Schematics API 

Before you begin using the IBM Cloud® Schematics API to deploy Slurm, review and complete the following prerequisites:



1.  Make sure that you have access to an IBM Cloud account and that you generated an IBM Cloud API key to authenticate to IBM Cloud.
2.  If the git repository that hosts the Terraform code is not public, generate a [personal GitHub access token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) for authentication. If you are using the [public IBM Cloud GitHub repository](https://github.com/IBM-Cloud/hpc-cluster-slurm) (broken link), you do not need to complete this task.
3.  Install the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli?topic=cli-install-ibmcloud-cli) and login to the IBM Cloud account through the IBM Cloud CLI.
4.  Install Python 3 or a newer version.
5.  Follow the [IBM Cloud Schematics SDK for Python instructions](https://cloud.ibm.com/apidocs/schematics?code=pythonintroduction) to set up and install the IBM Cloud Schematics API by using pip.
6.  Install all of the respective Python application dependencies that your Python code will be using, such as logging, os, yaml, and json, which are required when you use pip3 to run the application.





  Next steps 

After you've reviewed and completed the prerequisites for setting up the API, you are ready to [Create a workspace](https://cloud.ibm.com/docs/hpc-slurm?topic=hpc-slurm-creating-workspace&interface=api).
* [Liberty for Java buildpack defaults](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-buildpack_defauts)



* SDK for Node.js



* [Getting started with SDK for Node.js](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-getting-started-node)
* [SDK for Node.js](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-nodejs_runtime)
* [Use the startup command](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-startup_commmand)
* [Run the Node.js app locally](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-hints)
* [Enforce HTTPS on all pages in your app](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-nodejs-enforce_https)
* [Integrate third-party services using hooks](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-hooks)
* [Node.js buildpacks](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-nodejs_buildpacks)
* [Configuration options](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-configuration_options)
* [Available versions](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-available_versions)



* [Getting started with ASP.NET Core](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-getting_started-dotnet)
For instructions to configure the build job, see the [Configuring a Nexus npm build job in your pipeline](https://cloud.ibm.com/docs/services/ContinuousDelivery?topic=ContinuousDelivery-nexusconfig_nexus_npm) section.
11. Optional: If you are using a toolchain on IBM Cloud Public and you want to build your app by using Nexus with Maven, configure your pipeline to add a Maven build job. For instructions to configure the build job, see the [Configuring a Nexus Maven build job in your pipeline](https://cloud.ibm.com/docs/services/ContinuousDelivery?topic=ContinuousDelivery-nexusconfig_nexus_maven) section.





 Configuring a Nexus npm build job in your pipeline 

Before you configure an npm build job in your pipeline, you need a working pipeline that can use your build SCM repo as input, and you must configure Nexus for your toolchain. For instructions to configure Nexus, see the [Nexus](https://cloud.ibm.com/docs/services/ContinuousDelivery?topic=ContinuousDelivery-nexusnexus) section.

Configure the Delivery Pipeline to add an npm build job:



1. Create a stage and set the input to the appropriate SCM repo.
2. On the stage, add a build job.
3. Configure the build job:

Zoom

![npm build job](https://cloud.ibm.com/docs-content/v1/content/562806c0b18119f4d21cb66f5ae6d051634b4a16/ContinuousDelivery/images/nexus_npm_job.png)

Figure 1. npm build job

a. For the builder type, select npm (Artifactory or Nexus).

b.
rook-ceph-osd-2-dd4968b75-lzc6x 1/1 Running 0 4m40s
rook-ceph-osd-prepare-ocs-deviceset-0-data-0-29jgc-kzpgr 0/1 Completed 0 4m51s
rook-ceph-osd-prepare-ocs-deviceset-1-data-0-ckvv2-4jdx5 0/1 Completed 0 4m50s
rook-ceph-osd-prepare-ocs-deviceset-2-data-0-szmjd-49dd4 0/1 Completed 0 4m50s
rook-ceph-rgw-ocs-storagecluster-cephobjectstore-a-7f7f6df9rv6h 1/1 Running 0 3m44s
rook-ceph-rgw-ocs-storagecluster-cephobjectstore-b-554fd9dz6dm8 1/1 Running 0 3m41s











 Deploying an app that uses OpenShift Data Foundation 

You can use the ODF storage classes to create PVCs for the apps in your clusters.



1. Create a YAML configuration file for your PVC. In order for the PVC to match the PV, you must use the same values for the storage class and the size of the storage.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ocs-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: sat-ocs-cephfs-gold
resources:
requests:
storage: 5Gi
2. Create the PVC in your cluster.

oc apply -f pvc.yaml
3. Create a YAML configuration file for a pod that mounts the PVC that you created. The following example creates an nginx pod that writes the current date and time to a test.txt file.

apiVersion: v1
kind: Pod
metadata:
name: app
After the prerequisites and CI toolchain are successfully configured, proceed to the [Continuous Deployment (CD) toolchain introduction](https://cloud.ibm.com/docs/apps?topic=apps-tutorial-cd-devsecopsdevsecops-cd-toolchain-intro).





 Related content 



* [Getting started with clusters](https://cloud.ibm.com/docs/containers?topic=containers-getting-started)
* [Getting started with toolchains](https://cloud.ibm.com/devops/getting-started)
* [Getting started with Continuous Delivery](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-getting-started)







 Looking for help? 

Get help fast directly from the IBM Cloud Continuous Delivery development teams by joining us on [Slack](https://ic-devops-slack-invite.us-south.devops.cloud.ibm.com/).

For more support options, see [Getting help and support for Continuous Delivery](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-gettinghelp).





 Next steps 

When you have your prerequisites in place, continue to the next tutorial in the series:

[Part 2: Set up a Continuous Integration (CI) toolchain](https://cloud.ibm.com/docs/devsecops?topic=devsecops-tutorial-ci-toolchain).

This tutorial uses an example Node.js app, but you can also deploy other language-based apps.
* In the library: section, provide the URL of the HSM client image that you created in [step two](https://cloud.ibm.com/docs/blockchain-sw-252?topic=blockchain-sw-252-ibp-hsm-gemaltoibp-hsm-gemalto-part-four-docker). This is the client that the CA, peer, and ordering node will use to talk to the HSM daemon. The filepath: is the location of the shared object library in the image. If the image is not hosted publicly then the user must create the appropriate pull secret and specify it as well.
* In the envs: section, provide the list of environment variables that are required to configure the HSM.
* In the mountpaths: section, provide all the necessary artifacts such as config, shared object libraries, shared memory, etc. that are needed to communicate with the HSM daemon. These settings are vendor-specific as it is your responsibility to know what directories or files need to be mounted. When the CA, peer, and ordering nodes are deployed, these mountpaths will be mounted on to their containers along with the HSM client. Most of these mountpaths can be of type Memory, however, if there are files that need to persist, then set usePVC: true. When set, the operator stores the files in the mountpath in a persistent medium, by leveraging the PVCs of the CA, peer, and ordering node as the persistent medium.



Run the following command to create the configmap named ibp-hsm-config in your cluster namespace or project:

kubectl create configmap ibp-hsm-config --from-file=ibp-hsm-config.yaml -n <NAMESPACE>

The output looks similar to:

configmap/ibp-hsm-config created







 What's next 

After you have used these instructions to configure your IBM Cloud HSM and build the HSM client image, you are ready to configure your blockchain nodes to use the HSM.
sc.hadoopConfiguration.set(prefix + ".endpoint", "s3.direct.us-south.cloud-object-storage.appdomain.cloud")
sc.hadoopConfiguration.set(prefix + ".iam.api.key","<CHANGEME>")
val data = Array("Sweden", "England", "France", "Tokyo")
val myData = sc.parallelize(data)
myData.saveAsTextFile("cos://cosbucketname.cosservicename/2021sep25-1.data")
val myRDD=sc.textFile("cos://cosbucketname.cosservicename/2021sep25-1.data")
myRDD.collect().foreach(println)
}
}
Show more
2. Put SparkScalaExample.sbt in the src folder:

name := "ScalaReadWriteIAMCOSExample"

version := "1.0"

scalaVersion := "2.12.10"

libraryDependencies += "org.apache.spark" %% "spark-core" % "3.1.2"
3. Build the Scala project using sbt. Upload the resultant jar (scalareadwriteiamcosexample_2.12-1.0.jar) into Object Storage.

cd SparkScalaExample
sbt package

Upload jar to Object Storage.
4. Then POST the following payload JSON script called read-write-cos-scala-submit.json with your access key and password. Insert the Object Storage bucket name where the CSV file is located and the modify the endpoint path.

{
"application_details": {
"application": "cos://cosbucketname.cosservicename/scalareadwriteiamcosexample_2.12-1.0.jar",