Sample code to add docs with Docker

Here’s some sample code to get started with Rockset and Docker.

To Run:

• Put the DockerFile and test.py in the same directory
• Put your API Key in the DockerFile
docker build -f DockerFile -t docker-test .
docker run docker-test:latest

Here’s the DockerFile

FROM python:3.8-slim

ENV ROCKSET_APIKEY=YOUR APIKEY
ENV COLLECTION=loadtest
ENV API=api.rs2.usw2.rockset.com

ADD test.py /

RUN pip install --no-cache-dir rockset six

CMD [ "python", "./test.py" ]

Here’s the test file: test.py

from rockset import Client, Q, F
from datetime import datetime
import random
import string
import os

client = Client(api_server=os.getenv('API'), api_key=os.getenv('ROCKSET_APIKEY'))
collection = client.Collection.retrieve(os.getenv('COLLECTION'))

for x in range(0,10):
	body = {}
	body['id'] = x
	body['time'] = datetime.now()
	body['data'] = ''.join([random.choice(string.ascii_letters) for i in range(1000)])
	response = collection.add_docs([body])
	print(response)