This repository contains a prototype of TicTacSnow, a containerised game to deploy on Snowpark Container Services.
- Docker Desktop installed
- Python 3.10 installed
- A non-trial Snowflake account in a supported AWS region.
NOTE: Pre-reqs based on steps 1-2-3 of this Hands-On-Lab
- Run the setup/setup.sql code as ACCOUNTADMIN (re-used step 2 of the Quick Start linked above).
To get started with TicTacSnow, follow these instructions:
- Clone the repository to your local machine:
git clone https://github.com/matteo-consoli/tictacsnow/
- Build the Docker image locally:
# open terminal in the cloned folder
cd app
docker build -t tic-tac-toe .
- Login to the Snowflake Container Registry. Your <snowflake_registry_hostname> is -.registry.snowflakecomputing.com .
docker login <snowflake_registry_hostname> -u <username>
# Enter your password when prompted
- Tag the Docker image:
docker tag tic-tac-toe:latest <snowflake_registry_hostname>/container_hol_db/public/image_repo/tic-tac-toe:dev
- Check the list of Docker images:
docker image list
- Push the Docker image to the Snowflake Container Registry:
docker push <snowflake_registry_hostname>/container_hol_db/public/image_repo/tic-tac-toe:dev
-
Load Yaml on stage CONTAINER_HOL_DB.PUBLIC.SPECS.
Before uploading it, don’t forget to replace <snowflake_registry_hostname> with the value of your account: <your_org-your_account>.registry.snowflakecomputing.com
-
Check the Loaded File via SQL command:
USE ROLE CONTAINER_USER_ROLE;
LS @CONTAINER_HOL_DB.PUBLIC.SPECS;
- Create the new service: tic_tac_toe_service
-- Drop command in case you are creating the service again
-- DROP SERVICE IF EXISTS CONTAINER_HOL_DB.PUBLIC.tic_tac_toe_service;
CREATE SERVICE CONTAINER_HOL_DB.PUBLIC.tic_tac_toe_service
in compute pool CONTAINER_HOL_POOL
from @specs
spec='tic-tac-toe-spcs.yaml';
- Check the Service status. It might take a few minutes before the status "READY".
-- Check Status
CALL SYSTEM$GET_SERVICE_STATUS('CONTAINER_HOL_DB.PUBLIC.tic_tac_toe_service');
-- Once ready you'll have the status "READY", message "RUNNING"
-- Check Logs
SELECT SYSTEM$GET_SERVICE_LOGS('CONTAINER_HOL_DB.PUBLIC.tic_tac_toe_service', 0, 'tic-tac-toe', 50);
- Check the Service Endpoint assigned. It might take a few minutes before an endpoint is available. Once available copy it and paste it in a new window (not logged in).
SHOW ENDPOINTS IN SERVICE tic_tac_toe_service;
- Create a new user and role and use it in a new window to access your TicTacSnow instance!
-- Create your own user and password.
-- The user accessing TicTacSnow must have CONTAINER_USER_ROLE as default role.
CREATE USER TICTACSNOWPLAYER IDENTIFIED BY 'tictacsnow2024' DEFAULT_ROLE = 'CONTAINER_USER_ROLE';
GRANT ROLE CONTAINER_USER_ROLE to USER TICTACSNOWPLAYER;
- Login with the new credentials created and have fun!
Contributions are welcome! If you have any ideas, suggestions, or improvements for TicTacSnow, feel free to reach me out on Linkedin.
Don't forget to replace <snowflake_registry_hostname>
with the appropriate values for your project: .registry.snowflakecomputing.com