[NEW] Deploying a Discord Bot to Docker Containers || Discord.JS v13 2022

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
before this video starts i want you guys know that my patreon is like down below in the description if you guys want to support me if you guys choose to support me you guys can receive monthly benefit files being coding files that we code here in the series thank you so much for the support and i'll see you guys in the video so you've been sitting around watching fusion tear videos on how to create the ultimate discord bot in this tutorial i'm going to be showing you how to use docker containers to build your bot into a docker container let's get started first we're going to create a new file uh this one's just going to be called dockerfile this is going to be our docker configuration file it's going to tell docker all the configuration settings we want for our container that's going to house and run our bot first we're going to pull a base image we're going to pull the node alpine version alpine linux is a version of linux meant for running in containers it's very lightweight it's only five megabytes in size and it's a very stripped down version of uh it's a very stripped down operating system of linux so we're gonna pull that next we're gonna create a working directory within our container so we're gonna do work dur and in our case we're gonna put it in user source next we're going to copy over our npm package.json files this is going to allow the container to automatically build our npm package every time the this container gets built so we're going to copy package and then we're going to do star dot json and we're going to put in the current directory next we're going to run our npm install so we're going to run npm install the next step is copying over all of our bot files we're just going to do copy and then we're going to copy the current directory and we're just going to copy into the current directory which is going to be our working directory that we created on line 3. once we've copied over our bot we're ready to run it so we're going to do cmd and here we're going to specify node and then we are going to run it from our source folder bot.js once we've done that we've completed our docker file um this is a very basic file but if you have more complex requirements such as a database uh there will be more configuration here that you'll have to that you'll have to do so let's save this file and close it we're going to create one more file and this one's going to be called um this is going to be our docker ignore file and hit enter oh created that in the wrong section there we're just going to drag that down hit move in our docker ignore file we're going to specify folders that we don't want docker to copy over to our container so in this case we don't want our node modules we want the container to build our node modules uh when it gets copied over or when it gets uh executed so we're gonna do no modules uh if you had any npm logging turned on and you want to ignore any of those log files you can do that here so let's just do our npm debug dot log file even though we don't have one here when your [Music] bot gets more complex you may have logging turned on and you can just add the exclusion here so it doesn't get put onto your container we're gonna save that and close it next let's open a terminal so we're gonna build our bot um by running docker build and we're gonna build from the current directory uh we're gonna specify tac t to give it a name in this case i'm just going to call it v13 bot and hit enter so it's not going to execute all the information we put into our docker file you can see it's pulled down the node alpine version it's created our working directory it's copied our package.json files over and it's now running our npm install looks like it's downloaded 33 packages onto our container it's copying over our source code setting up the default execution line here and our container is built so now if we go docker images you can see our v13 bot is right here built 13 seconds ago so let's go ahead and start our docker container so we do docker run we're going to do tac d uh this is going to allow it to run as a daemon and run in the background on our computer it does require a computer to be online but if you're moving this up into the cloud onto aws or digitalocean uh some sort of kubernetes cluster obviously it can be available 24 hours a day seven days a week we're also going to specify tactac rm this is going to automatically delete the container off the running machine when it's completed again if you're running a database you're going to want to change this we're then going to specify our container b13 bot is what we called it and then we're just going to hit enter it's going to output an id this is our container id that's running uh we're going to do docker ps and this is going to tell us that our v13 image is running it was created 17 seconds ago and is online so let's go to discord and see if our bot is online as you can see in the side here maker blinkerbot is online let's try and run one of our commands and see if it responds bang that response indicates the bot is online and running um so next let's shut it down so we do docker stop and then you just specify the container id at the end of the line here so we're just going to just paste that in and hit enter and that concludes today's video on docker with discord.js i hope you guys learned something here in today's video if you did smash like button hit subscribe with post notifications so you guys never miss an upload in this series thanks again to maker blake for making this video here for me today he actually taught me something a little bit about docker myself since i didn't know too much about it leave a comment down below if you want to see any more videos from blake thanks again for watching and i'll see you all in the next video you
Info
Channel: Fusion Terror
Views: 10,004
Rating: undefined out of 5
Keywords: fusion terror, docker, docker discord bot, docker containers discord.js, docker containers for discord.js, Deploying a Discord Bot to Docker Containers, how to deploy a discord bot to docker containers, docker tutorial, docker container, docker + discord.js, Discord.JS v13, How To Make A Discord Bot, how to code a discord bot, using docker for a discord bot, Node.js, node js docker image, node.js docker
Id: qp2pgLtb2Cw
Channel Id: undefined
Length: 6min 32sec (392 seconds)
Published: Mon Apr 25 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.