Native App + Container Services (Intro)
Goal of this tutorial is to get a introduction to Native App + Container Services. In this tutorial you will build a containerized website and then deploy it via a Native app + Container Services. This is the same container we used in our container services introduction tutorial.
Video
Requirements
- Be in a container services enabled region.(Link)
- You can NOT be on a trial account. (Link)
- Please install docker desktop - https://www.docker.com/products/docker-desktop/
Download (Choose 1)
Setup
Lets go through some setup before going to docker / building our native application.
Snowflake
Let's start by setting up Snowflake before we jump to docker. Create a worksheet in Snowflake and add / run the code below.
Note
Copy the resulting URL, we will use it in Docker later.
repository_url |
---|
sfsenorthamerica-wilczak-videos2.registry.snowflakecomputing.com/raw/website/images |
Upload Native App Files
In this section we will go back to our "provider_db/provider_schema" database/schema and upload our native app code we got earlier into the "code" stage.
Next we'll take the files from the "stage" folder and upload them.
Docker
Our goal is to run the application locally and check if it works and then upload the built docker image to our snowflake image repository so it can be hosted on Snowflake container services followed by a Native App.
Note
Please install docker desktop and have it running - https://www.docker.com/products/docker-desktop/
Using terminal, navigate into the "website" folder. And run the code below to build the application locally.
Now you can go to Localhost or the direct local url http://127.0.0.1:8080/. To see what the website will look like before we upload it. Press Ctrl+C to stop the application.
Upload
Now that we have our image created. Lets upload it to Snowflake. We will need our Snowflake image url (1) that we got from our Snowflake setup.
-
repository_url sfsenorthamerica-demo-dwilczak.registry.snowflakecomputing.com/provider_db/provider_schema/docker
Next docker login to our snowflake image repo using only the part of the url prior to the first forward slash. We will use the user with accountadmin access.
Finally push the image to your image repository living on Snowflake.
Using default tag: latest
The push refers to repository [sfsenorthamerica-demo-dwilczak.registry.snowflakecomputing.com/provider_db/provider_schema/docker/website]
df7fb4f01ad1: Pushed
620025ace117: Pushed
3e2bded7d904: Pushed
4ad6620b3816: Pushed
6828fc9c1ffb: Pushed
4a40ad7ca2cf: Pushed
064ffeaf7830: Pushed
28f8d0721800: Pushed
cbe4fb5e267b: Pushed
734c0f0b65c2: Pushed
8845ab872c1c: Pushed
d7d4c2f9d26b: Pushed
bbe1a212f7e9: Pushed
latest: digest: sha256:1d6431ee1c749261d35129ee07ebc34ea2868fe2473e0b226078cf774951dc99 size: 3045
Build Application
Now were ready to build our application package and test it by building/testing it in our Snowflake account. Lets go back to our worksheet and copy the code below.
status |
---|
Application 'CONSUMER_APP' created successfully. |
Using the App
Lets walk through the prcoess of installing the application. Lets click on our new application called "consumer_app".
Grant the application the privligies to create a warehouse, compute pool, and endpoint to acccess the website.
Click activate, this will start the build process.
Warning
I recommend to refresh the screen once in a while, the UI might just hung up.
The build will go into a loading screen. This can load for upward of a few minutes for a simple application and longer for more complex apps.
Once the application is installed we can launch the app.
We'll login with a user who has the accountadmin role.
Now we can see the amazing website we have made in Native apps and Container Services on Snowflake.
(Extra) Sharing
Warning
Your second account will also have to be enabled.
If you want to share your application, you will have to set a default version.