Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    Deploy a Docker project with Zeit’s Now

    mykola bilokonskymykola bilokonsky

    Use Zeit’s now to deploy a docker container to the cloud quickly and easily. We will see that the process is exactly the same as deploying a Node project. This lesson will also show how log information is displayed on the generated url by Now while the app is being deployed.

    zeit-nownow
    dockerDocker
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    00:00 In addition to natively parsing package.json files and making node applications super easy to deploy, Now from Zeit is also capable of parsing Docker files.

    00:11 What this means is that, in addition to JavaScript projects, you can also deploy projects written in the custom language that you wrote in grad school and have never used for anything but want to deploy a service in or whatever, anything. Anything can be run inside of Docker because it's just a virtual Linux container.

    00:32 To prove this point, we're going to run some PHP code here and show you that PHP is as easy to deploy with Now as JavaScript. Here's our Docker file and don't worry if you don't know what this is. We're going to have some Egghead Lessons on this soon.

    00:46 If you look at it, what we're basically saying is go grab a template. In this case, an apache2 Docker container. Give it a name. Run a little bit of code. In this case, we're just updating our dependencies. Copy this file from the local computer into this location on the Docker's container. EXPOSE port 80 and then start apache2.

    01:07 What is our file? It's just like our node example file. It's a clock. It's spitting out the current time, but this time, it's using PHP codes. It's going to render that on the server and spit it out. How do we deploy this with Now? We just type now.

    01:25 Docker files in my experience take a little bit longer than node projects, but it gives us a URL. That gives me a good opportunity here to show you something cool. As your application is deployed in Now, it logs all this stuff out to the terminal, but it's also logging this out to the URL.

    01:45 You'll notice the URL is something that it gives you right away. It doesn't wait until the whole thing's deployed before giving the URL. Instead it gives you this, and then you can put this up there and already share it around.

    01:55 Even if your Docker install takes a minute or two, because it's going to pump all of these logs out to the browser via, I assume, Web sockets or something. Then as soon as this whole thing is done, it's going to redirect and show you the index.php page. If we watch this for a second, we see it storing. There we go. Now, we're all set.

    02:18 Now, all we have to do is go to clock.php. We can see that our clock is running and hasn't been deployed by a docker. Now, all the same rules hold true. You notice that screws up my CLI there for a minute. If we run Now again without making any changes, you can see that it's giving us the same URL. It's not jumping through any of those hoops.

    02:46 This is still an immutable deployment, but now, instead of a node application, we're running something in any language, in this case PHP, and sticking it out there. That's really awesome because that means that we can now officially use Now to deploy any of our code anywhere with three letters on the command line.

    Discuss

    Discuss