Feedback in seconds

Get feedback in seconds with on-demand Instant Previews.

This post introduces how you can use Namespace's infrastructure to bring up on-demand preview environments, running one or more containers. Preview environments bring collaboration to development and testing.
Get started with Namespace — it takes less than a minute.

When we're in single-player mode, debugging or testing our products, we're often interacting with them. Calling APIs, interacting with UIs, running tests.

But then, sending those changes to review, or asking for feedback from a teammate, we resort to code.

Check out this PR, does this make sense to you?

And our colleagues resort to healthy imagination thinking through the consequences that our changes will have on the actual product.

Well... You could start your stack, and then use Tailscale to get your teammate to access it. Or maybe start a local reverse tunnel like ngrok or Cloudflare tunnel.

Oh, you're trying it now? Sorry, had started working on a different change. Let me restart it.

Oh, now? I had just taken a quick break and my laptop went to sleep. Let me restart it.

Can be a pain to get feedback.

Preview environments are a great leap forward.

They snapshot your progress, and make it available so others can try the changes, without you having to do a thing about managing any environment.

Instant Previews

Creating previews takes only a couple seconds, with nearly zero effort.

We will use an example Django app to show how simple it is to use Namespace Previews. If you don’t have Namespace installed yet, now’s a good time to install it.

Or we can break the suspense... just run:

curl -fsSL https://get.namespace.so/cloud/install.sh | sh
nsc login

Then fetch our example:

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

To keep things simple, let's use Namespace's Remote Builder to build the app and to push the image to Namespace's Container Registry.

However, any build process and container registry would work.

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

Now, we are ready to run the preview. We know the Django app listens on port 8000, so let’s 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

That’s it! Namespace created a preview environment from our app within a few seconds, making embedding previews in the development workflow easy.

And because you can run as many as you want, too easy is not really a problem.

Let's wrap up those commands in a summary:

Build the app: nsc build . --name nsc-django-app:v0.0.1 --push

Create a Preview: nsc run --image nscr.io/8enum0hp1l5ii/nsc-django-app:v0.0.1 -p 8000

(Using docker compose? There's a compose version too!)

Behind the Scenes

Under the covers, Namespace created an ephemeral environment, started the container, and exposed it's port 8000 behind our programmable ingress. That gets your authentication and TLS termination for free.

And the ephemeral environment that we created? No need to worry about it, you won't be charged more for how long it is running. We automatically manage it's lifecycle for you.

Internet-facing, but protected

Since the preview runs in the cloud, all URLs are already sharable.

But by default they're not public; only members of your workspace can access it.

Following the URL, you will be able to access the Django app preview if you are logged in.

django page preview

You will see the sign-in page instead if you are not logged in or don’t have access to the workspace.

auth page for preview

Debug the Preview

Container logs are streamed live to our Namespace dashboard. You will see the logs directly from the running container when opening the cluster page that hosts your preview (9a7a07dmi91vo in the above example).

Any workspace member gets access to the same logs too.

logs page

Beyond logs, you can also jump into a shell.

You can switch to the dashboard UI’s terminal tab or open an SSH connection from the CLI.

$ nsc ssh 9a7a07dmi91vo
> nerdctl ps
CONTAINER ID  IMAGE                                        COMMAND                   CREATED        STATUS  PORTS                    NAMES
673913efdd32  nscr.io/8enum0hp1l5ii/nsc-django-app:v0.0.1  "python3 manage.py r…"    2 minutes ago  Up>8000/tcp  nsc-django-app-tm63o
> curl
<!DOCTYPE html>
<html lang="en">...</html>

Wrapping up

Previews can really level up your team collaboration.

And while you can set these up on your own too, Namespace brings you the confidence of being able to empower your team, without being worried about how much it will cost ya.

We are developers too, and we have a love for developer experience, and predictable pricing.

Share this story on Twitter, or follow us for updates.
Join the conversation with the team on Discord.

Subscribe to updates

Updates, guides, and other posts where we talk about the industry.