‫This is me walking through the assignment for the secrets compose file that we're going to put
‫in our swarm stack.
‫This file was left over from our previous assignment when we were dealing with Drupal.
‫That was under a compose assignment 2 directory.
‫Now I'm up at the top here, and I know we covered this previously but I didn't mention it in the slide,
‫is that this version needs to be 3.1.
‫Because a stack and swarm will not accept any secrets in a file unless it's at minimum 3.1
‫compose format.
‫The worst case, though, is if I left it at the 2 and I forgot, when I try to deploy my stack, it'll
‫just say, 'Sorry, cannot use compose version 2 file.' So, it'll just be pretty obvious that you need to change
‫it.
‫All right. The next one was, I needed to change this image. We're not going to build a custom image
‫on our stack because, remember, swarm doesn't build.
‫At least not in the current version.
‫We're going to...um...go back to the official Drupal, 8.2, because in production, we should always pin our versions.
‫I'm going to just get rid of this build here. Technically, in a stack,
‫I can leave the build command here, but it'll just ignore it.
‫I'll actually just tell us, 'Hey. Don't need this build.
‫I'm not going to use the build. I'm going to just pull down the image.
‫Thank you.'
‫We could just leave it, but I'm going to, for this example, not be distracted by that thing and just
‫delete that line. Then I'm going to go down here to the environment, and we need to change this because
‫we're no longer going to use an actual password. We're going to use the file.
‫Then this is so this postges is just like the previous lectures where we talked about how the official
‫images now have this option for the file to support secrets.
‫Now I just have to give it the location of the file instead of the actual secret itself.
‫So, run secrets and we're going to call this one psql pw.
‫And then I need to actually specify the secret.
‫So, down here, under secrets, I want to call it psql pw. Then it's going to be external, which means
‫that we're creating it on our own from the command line and that it's not the stack's responsibility to
‫create it.
‫This is actually just a boolean value.
‫So, I specify that as true.
‫Oh, and then I almost forgot. I go up here,
‫I've got to add the secrets. I have to list it.
‫All right.
‫That looks good to me.
‫We're going to copy this over to the server on node1 of our swarm, and then we'll give the stack
‫a shot.
‫OK.
‫I have copied over the compose file from my local machine, so we should be able to do a docker
‫stack deploy now, -c docker compose, and I'm going to call it drupal.
‫And that's what happens when you forget to create the secret first.
‫So, just like the instructions said, I'm going to create the secret, and I'm going to just put some random
‫characters in here.
‫docker secret create psql pw, pass in the value.
‫OK.
‫Now, I should be able to deploy the stack. There we go.
‫So, docker stack ps drupal.
‫I've got my postgres and my drupal.
‫So I should be able to bring up a browser and go to node1 8080, and there we go.
‫I can install a Drupal.
‫Let's actually test to see if that password worked.
‫This is not actually required, but I just want to test it anyway.
‫postgres...postgres...postgres...
‫Database password...
‫postgres...there it goes! It worked!
‫All right.
‫And we're done.