logo

Previews

Fast and secure Previews for developers who want rapid feature sharing and iteration.

Sharing your changes with your teammates to get early feedback is a crucial step of software development lifecycle. Traditional workflows expect you to pack your changes in a pull request and wait minutes for the preview to be created. Today, you can use Namespace to spin up an ephemeral preview environment and get a public authenticated URL in less than 6 seconds.

Create a Preview

We will use an example Django app to show how you can use Namespace Previews. This app exposes its frontend to port TCP/8000.

Clone the repository locally.

$ git clone git@github.com:namespacelabs/examples-nsc-build-simple.git && \
  cd examples-nsc-build-simple

We are going to build the Docker container using our Builder and push the image to our Workspace private registry. However, any container registry would work just as fine. The --name flag will tag the image with your Workspace's registry repository (nscr.io/8enum0hp1l5ii in our example).

$ nsc build . --name nsc-django-app:v0.0.1 --push
 
  Pushed for linux/amd64:
    nscr.io/8enum0hp1l5ii/nsc-django-app:v0.0.1

Now we are ready to run the preview. We know that the Django app listens to port TCP/8000. So, we are going to tell nsc to expose that port.

$ nsc run --image nscr.io/8enum0hp1l5ii/nsc-django-app:v0.0.1 -p 8000
 
  Created new ephemeral environment! (id: 9a7a07dmi91vo).
  More at: https://cloud.namespace.so/8enum0hp1l5ii/cluster/9a7a07dmi91vo
 
  Running "nsc-django-app-tm63o"
    Exported 8000/tcp as https://q02h2n0-9a7a07dmi91vo.fra1.nscluster.cloud

Behind the scene, Namespace creates an ephemeral environment, starts the container and generates the public URL. The ephemeral environment runs for 30 minutes.

The URL is authenticated. That means only the members of your Workspace are able to open the preview.

If you are logged in and you are a member of the same Workspace, then you will see the Django app preview.

django page preview

If you are not logged in your browser or you are not a member of the preview's workspace, you will see the sign in page. Such as follows.

auth page for preview

Debug the Preview

Container logs are streamed live to our Namespace dashboard. If you open the cluster page that hosts your preview (such as 9a7a07dmi91vo in the above example), you will see the logs directly from the running container.

logs page

What's Next?