Skip to main content

Posts tagged with 'c'

Vance Feldman is a developer and an artist who faced technical challenges when bringing his ForeverScape artwork to mobile devices.

Show notes:

If you're interested in Henry Darger, check out this clip from NPR's All Things Considered. If you're interested in SuperJail, you can watch it on Adult Swim.

Want to be on the next episode? You can! All you need is the willingness to talk about something technical.

Theme music is "Crosscutting Concerns" by The Dirty Truckers, check out their music on Amazon or iTunes.

I got my "Hello Express" example working on Docker for Windows. I see the potential benefit of putting a (node) app in docker, but am I meant to actually develop this way? It seems like a lot of steps to create a package each time I change code. There must be something I'm missing: please leave a comment to let me know.

I also took the time to update the version of Node I was using. It was painless: I uninstalled the old version and used choco install nodejs. This installed node 6.2.2 (code named "slim"?) and npm 3.9.5. I ran my hello world and hello express code, and they still worked fine.

To start with, I created a brand new express project:

express hello-express-docker
cd hello-express-docker
npm install

And then, I opened it with Visual Studio Code.

code .

By the way, you can open up a console window from within Visual Studio Code. View -> Toggle Integrated Terminal (or Ctrl+`).

Next, I pretty much followed the instructions on how to Dockerize a Node.js web app. First, I created a Dockerfile in the hello-express-docker folder. This is just a text file named "Dockerfile". Inside that file, I put:

# I used node:slim which corresponds to 6.2.2 I guess
FROM node:slim

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
COPY . /usr/src/app

# Expose the port
EXPOSE 3000

# kick off the express site
CMD [ "npm", "start" ]

Note that I used a different port number than the instructions, because that's what express's default seems to be (not 8080 as the instructions indicate).

Next I created a docker package.

docker build . -t ccc/hello-express-docker

The tag isn't strictly necessary; the ccc stands for "Cross Cutting Concerns" :)

Once that's done, you can list all the images you have with:

docker images

I have some other images that I downloaded from the docker hub, including couchbase, nginx, ubuntu. You should see at least the ccc/hello-express-docker package listed.

Now that I have an image, I'll run it just like any other docker image:

docker run --name hello_express_docker -p 49160:3000 -d ccc/hello-express-docker

Port 49160 is just an arbitrary port. Once that's running, I can visit my site in a browser: http://docker:49160 (docker is the host name that Docker for Windows uses. If you are using Mac, Linux, Docker Toolbox, etc that may vary).

And that's it! Now my hello-express site is running in a container. If I were done, I guess I could give this container to devops for deployment. I'm struggling to see why I would do this on a day-to-day basis as a developer. Maybe I can have the docker container "mount" my working folder so I can make changes with Visual Studio Code. Or vice versa?

Calvin Allen is a developer who is using Chocolatey NuGet to automate the setup of development environments and is also creating Chocolatey packages of his own.

Show notes:

Calvin Allen on Twitter

Want to be on the next episode? You can! All you need is the willingness to talk about something technical.

Theme music is "Crosscutting Concerns" by The Dirty Truckers, check out their music on Amazon or iTunes.

Podcast preview - July 2016

June 29, 2016 mgroves 0 Comments
Tags: podcast

I've been busy recording podcast episodes with some GREAT guests, and I thought I would give you a quick preview of what's to come.

Subscribe now!

Coming soon on the Cross Cutting Concerns podcast in July 2016:

  • Calvin Allen on Chocolatey NuGet
  • Vance Feldman on the ForeverScape artwork and mobile app
  • David Giard on Cognitive Services from Microsoft
  • Matt Bok on home automation tech

And there's even more coming! Subscribe now with your podcatcher of choice.

Want to be on the next episode? You can! All you need is the willingness to talk about something technical.

I'm trying to familiarize myself with node.js, since it seems to be in use by a lot of Couchbase customers. I heard that Visual Studio code had some pretty good node.js support built in, so I decided to give it a shot.

I already had node and npm installed on my Windows machine. I don't remember why. If you aren't sure if you do, open up Powershell (or cmd) and try:

node --version

and

npm --version

(If metaphors help you, I think of node as ASP.NET and I think of npm as NuGet)

If neither of those commands works, then you can install node with Chocolatey NuGetchoco install nodejs

The next easiest thing you can do is create a file with text editor, say "app.js". Put this into that file:

var msg = "Hello, world!";
console.log(msg);

Woo. Now back at the command line, type:

node app.js

And guess what it will write out? If you guessed "Hello, world!" then give yourself 10 points.

So, what good is this? Well, you can now write programs in JavaScript outside of a browser. A lot of people use this to write server-side JavaScript, for example. They might use a framework like Express (which, back to the metaphors, I think of as ASP.NET MVC). You can use npm to install express and an npm "start" command to run your Express app. I may blog more about that later, after I play with it some more.

Matthew D. Groves

About the Author

Matthew D. Groves lives in Central Ohio. He works remotely, loves to code, and is a Microsoft MVP.

Latest Comments

Twitter