https://www.ibm.com/support/knowledgecenter/SSMNED_5.0.0/com.ibm.apic.install.doc/tapic_docker_install.html
By installing IBM® API Connect in a
Docker container, you can run a complete
IBM API Connect on-premises environment on your
local machine. A Docker container
installation of IBM API Connect is only for
development use; it is not supported in a production environment.
Before you begin
You must install the following software on a supported operating system:
- docker 1.12.0 or later.
- docker-compose 1.8.1 or later.
About this task
To install and configure
IBM API Connect in a
Docker container, complete the following steps:
To verify that you can deploy and use an API, complete the following steps:
Procedure
- Install IBM API Connect in a Docker container.
- Create a git clone of the IBM API Connect
Docker repository by entering the following command:
git clone https://github.com/strongloop/apiconnect-docker
- Review the terms of the license agreement by entering the following command in the root folder of your local repository clone:
docker run -it --rm --env SHOW_LICENSE=1 ibmcom/apiconnect:manager-v5.0.6.0
- In the root folder of your local repository clone, edit the file .env, specify the details for your SMTP server, and accept the license, by modifying the parameters in the file as follows:
ACCEPT_LICENSE=true
SMTP_HOST=smtp_server_hostname_or_address
SMTP_PORT=smtp_port_value
SMTP_SENDER=sender_email_address
SMTP_USERNAME=smtp_username
SMTP_PASSWORD=smtp_password
where:- (required) smtp_server_hostname_or_address is the host name or IP address of your SMTP mail server.
- (required) smtp_port_value is the port value of your SMTP mail server.
- (required) sender_email_address is the email address from which API Connect emails are sent.
- (optional) smtp_username is the username required to send emails through the SMTP mail server.
- (optional) smtp_password is the password for the SMTP username.
Important: The ACCEPT_LICENSE=true entry is commented out by default, you must remove the preceding # character.
- Ensure that your Docker virtual host has the following minimum resources:
- In a Docker
terminal window, change to the root folder of your local repository
clone, and run the following command, depending on whether you want to
use DataPower® Gateway or Micro Gateway as the gateway service:
docker-compose up -d
docker-compose -f docker-compose-microgateway.yaml up -d
The command will take a while to complete. - Confirm that the IBM API Connect services are running by entering the following command, depending on whether you want to use DataPower Gateway or Micro Gateway as the gateway service:
docker-compose ps
docker-compose -f docker-compose-microgateway.yaml ps
You should see a response similar to the following (if you are using the Micro Gateway, microgateway is listed instead of datapower): Name Command State Ports
------------------------------------------------------------------------------------------------------
apim /tini -- /startup.sh Up
datapower /start.sh Up 443/tcp
dockercompose_make-ssh-keys_1 /bin/sh -c /genkey.sh Exit 0
esmaster /docker-entrypoint.sh /bin ... Up 9200/tcp, 9300/tcp
ibmlogstash /bin/sh -c /startup.sh Up
ibmportal /root/tini -- /root/start_ ... Up
microservice /bin/sh -c /usr/bin/app.sh ... Up 8080/tcp
nginx /bin/sh -c /run.sh Up 0.0.0.0:443->443/tcp, 80/tcp
- To enable access to all the services, edit your local /etc/hosts file to map the IP address of your Docker host to the IBM API Connect host names, depending on whether you want to use DataPower Gateway or Micro Gateway as the gateway service, as follows:
docker_host_ip_address apim ibmportal datapower microservice
docker_host_ip_address apim ibmportal microgateway microservice
- Configure your IBM API Connect cloud.
- Open the Cloud Manager user interface in a browser by entering the following URL:
https://apim/cmc
- Log in with the following credentials:
Username: admin
Password: !n0r1t5@C
- Accept the license agreement.
- On the Create your profile page, enter your email address, and a new password, then click Update profile. The Cloud Manager user interface opens.
- Configure the Management service by completing the following steps:
- Click Services, then in the DataPower Services pane click the Service Settings icon .
- Enter datapower in the Address field, then click Save.
- In the DataPower Services pane, click Add Server, then enter the following details:
Display Name: idg
Address: datapower
Username: admin
Password: admin
- Click Create to add the server.
Note: This operation might take a while to complete.
- Add a new provider organization by completing the following steps:
- Click the Organizations tab, then click Add.
- Enter a Display Name and Name of your choice.
Note: The value of the Name field is included in the organization segment of the URL for API calls.
- Click New User and enter your email address in the Email field.
- Click Add to create the provider organization. An invitation email is sent to the specified email address.
- In the invitation email, click the activation link and follow the instructions to sign up.
- When you have completed the sign up instructions, the login page for the API Manager user interface opens; log in with your email address and password.
The
API Manager user interface opens. To reopen the
API Manager in the future, use the following URL:
https://apim/apim
- Configure your IBM API Connect Catalog.
- In the API Manager user interface, click the Navigate to icon , then click Dashboard.
- Click the Sandbox Catalog to display its details.
- Customize the gateway endpoint by completing the following steps:
- Click the Settings tab, then click Endpoints.
- In the Custom Gateway URL field, enter https://microgateway.
- Click the Save icon to save your gateway customization.
- Enable the Developer Portal in the Sandbox Catalog by completing the following steps:
- Click the Settings tab, then click Portal.
- From the Select Portal drop-down, select IBM Developer Portal. The URL is set automatically to the following value:
https://ibmportal/organization_name/sb
where organization_name is the Name value that you specified when you created the provider organization in step 2.f. - Click the Save icon to save your Developer Portal configuration.
After a few minutes, you will receive an email with a link to the Developer Portal site for the Sandbox Catalog. The link is single use only link for the administrator account. When the link is active and you have accessed it, you can change the password of the administrator account.
- Publish a microservice application to the Sandbox Catalog.
- Install the IBM API Connect
developer toolkit; for details, see Installing the toolkit.
- Open a command window and navigate to the /apim/docker/docker-compose/microservice folder in your local repository clone.
- Enter the command apic login, and supply the following details in response to the prompts:
- Server: apim.
- Username: your API Manager user interface account email address.
- Password: your API Manager user interface account password.
You should receive the response Logged into apim successfully. - Enter the following command (all on one line):
apic publish definitions/loopback-example-database-product.yaml --catalog sb
--organization organization_name --server apim
where organization_name is the Name value that you specified when you created the provider organization in step 2.f.
- Configure the Developer Portal.
- Open the Developer Portal user interface by entering the following URL:
https://ibmportal/organization_name/sb/
where organization_name is the Name value that you specified when you created the provider organization in step 2.f.You can see the loopback-example-database 1.0.0 microservice in the Featured APIs pane.
- Click Create an account and follow the instructions to create a Developer Portal account. An invitation email is send to the specified email address.
Note: You cannot use the same email address as the one you used in step
2.f.iii when creating your provider organization, because this email address is used for the
Developer Portal admin account.
- Follow the activation link in the invitation email, and log in to the Developer Portal as a developer by using the account credentials you just specified.
- Create an App by completing the following steps:
- Click .
- Enter microservice for the title, and a description of your choice, then click Submit.
- Select the Show Client Secret check box and make a note of your client secret because it is displayed only once. You must supply the client secret when you call an API that requires you to identify your application by using a client ID and client secret.
Note: The client secret cannot be retrieved. If you forget it, you must reset it.
- The client ID is hidden; to display the client ID for your application, select the Show check box for Client ID, and make a note of it. The client ID is displayed and can be hidden again by clearing the check box.
- Optional: You can add an additional client ID and client secret to the application. For more details, see Registering an application.
- Subscribe to a Plan by completing the following steps:
- Click API Products, then click loopback-example-database (1.0.0) to open the Product details page.
- Click Subscribe to subscribe to the default Plan.
- Select your microservice App, then click Subscribe.
Note: It takes up to 10 minutes for the
Micro Gateway to synchronize with the
API Connect Management server. The subscription credentials will be accepted by the
Micro Gateway after the synchronization is complete.
- Access the microservice APIs through the gateway.
Note: The following commands use sample client ID and client secret values. You must replace these with your own credentials that you derived in step
5.d.
- Access the POST API through the gateway by running the following command:
curl -k --request POST \
--url endpoint_url \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-ibm-client-id: ad37d0e2-4551-41f7-a011-88f0447f4560' \
--header 'x-ibm-client-secret: yY7xL8hA0iD1tR0qD5hY0kG3rR3nC2eA3mM8iN2yL4hD2bQ2gU' \
--data '{"email":"myemail@myhost.com","createdAt":"2016-11-26T15:29:45.233Z","lastModifiedAt":"2016-11-25T20:17:02.033Z"}'
- Access the GET API through the gateway by running the following command:
curl -k --request GET \
--url endpoint_url \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-ibm-client-id: ad37d0e2-4551-41f7-a011-88f0447f4560' \
--header 'x-ibm-client-secret: yY7xL8hA0iD1tR0qD5hY0kG3rR3nC2eA3mM8iN2yL4hD2bQ2gU'
where endpoint_url has the following value depending on whether you are using the DataPower Gateway or Micro Gateway as the gateway service:
댓글