Loading video player...
Hey everyone, in this video we're going
to talk about Dockerizing NextJS and
deploying it to a VPS. So we're going to
look at the latest Nex.js. For this,
it's Nex.js version 16 at the time of
recording. We can deploy Nex.js in
multiple ways. So they actually have an
overview here on the Nex.js website, but
you can see one of those options is
actually with a Docker container. If I
click on that, they have a short
description here where they mention
Docker deployments support all Nex.js
features. And they also mention that
while Docker is excellent for production
deployments, they do mention just using
a local development server, MPN rundev,
uh for local development. All right, so
I'm going to use the latest Nex.js 16
and actually it has a different minimum
NodeJS version. So in a previous video
of mine, we actually uh deployed NexJS
with Coolify and was using the latest
Nex.js 16 and by default on Coolify, it
was using an older NodeJS version. So we
actually ran into an issue there.
However, we were still able to fix it by
just increasing the NodeJS version that
was used, right? So, it's good to know
about that. Now, if you scroll down
here, you will see some templates that
they have prepared for you. So, if you
click on the first one there, they have
a repo here with a docker file. So, here
they have an example docker file here.
So, we'll talk about this in a second.
Now, we need some NextJS app to actually
dockerize. So, I have a NexJS
application here. It's very simple, but
it does use the NextJS image component.
It uses a server action. If I click on
that, we actually get a result back from
the server action. I also have a route
handler here. And if I click on this
button, I get a message from the route
handler. Right? So it's full stack both
client side and server side is in here.
I also have some navigation. So if I go
to / test, we have a different page.
Right? So just some basic link
navigation. So I want to dockerize this
next.js application and ultimately I
want to run it in production on a VPS.
Now on the VPS, we also talk about
adding a custom domain as well as adding
a CDN in front with Cloudflare and
adding HTTPS. So more production-l like
setup on the VPS as well. How do I go
about doing this? So I'm going to show
you two ways to do this. So the first
option that you have that I'm going to
show you is to create a Docker image out
of your application here on your own
computer first. So this Docker image
will contain everything that is
necessary to run this next.js apps,
right? So a docker image is basically
like a package that contains all the
dependencies, all the things that it
needs to run and then we can move that
to the VPS and run it on the VPS. And so
I'll show you that first. The second
option that you have is if you use a VPS
provider that can build that Docker
image for you, then you don't even need
to build it yourself anymore. They will
do it for you. So that's why I'm going
to use Hostinger in this video. Yes,
they are sponsoring, but they have a
great tool here called the Docker
Manager, which means we do not have to
build a Docker image locally. They will
build it for you. So, I'll show you that
as the second option. Okay, but let's
start by building a Docker image out of
our application here. Right. So, I have
my NextJS application here, NextJS 16
here. Package.json. You can see it's
version 16. Uh you just saw how it
works, right? So we have a page
homepage. We have a server action. We
have a route handler and we have a
different page here as well with
navigation on the homepage. I'm also
using that next.js image component. So
now I need to create a docker image out
of this. If you go if you search for
nextjs docker you will find this article
here and here there's an option for
docker container. Now if you go to their
templates the first one here will be a
repo here on github that has that is an
example next.js app with a docker file.
So, if I open up the Docker file, this
is a so-called Docker file. So, we can
just copy that. And I'm actually I'm
going to create a new Docker file here,
uppercase Docker file, and just paste
all of that in here. So, this will allow
us to create an image, Docker image out
of that out of our NextJS app. It
describes what it needs, what to copy
into the new into that image. And there
are perhaps ways that you can change
this and fine-tune it to fit your needs.
I will just leave it as this example,
though. So basically you can see it's
pulling in NodeJS as a like a base image
right because NexJs needs NodeJS to run
right. So it's using a particular
version. It's going to install
dependencies right because our Nex app
needs other dependencies right it's
going to run a build to create an
optimized version. It's going to set the
note environment variable to production.
It's going to copy things from the
public folder right some some assets
that we may have like like images or PDF
files. And it's going to expose a port
on number 3000. So you can change this
but I will leave it for now. There is
another file in that repo called docker
ignore. I will also copy this and I will
create dot docker ignore and I'll paste
this right here because remember it's
going to copy over some things into that
image and uh we do not we do not want to
copy some things in there like so we can
ignore these things. All right. Now I'm
going to use docker desktop here to
manage all of this. So if you have not
installed this yet go ahead and install
this. If you search for Docker Desktop,
you you'll find it on the Docker
website, right? I'm on Mac, so I just
had to install this, but you can pick
the right option for you. All right.
Now, once you've installed Docker
Desktop, you will see this. So, I have
my images here. So, right now, I don't
have anything here. So, what we want to
do is create an image out of our next JS
app, right? So, it will appear here. And
then an actual instance of that when we
actually run it, that's called a
container. Okay? But first, we need to
have an actual blueprint or like package
to create instances out of. So now let's
actually create a uh docker image. We
can do it in two ways. So the first way
is to do it in the terminal. So you can
run a terminal command. So what I wrote
here is uh docker build, right? So build
an image. How does it know what to like
where are the instructions for building
that? Well, I have a period here which
means in this directory there will be a
docker file. So from this docker file
here are the instructions to create an
image. Now I have provided two options
here. I have this platform Linux AMD64.
This may be necessary if you're on
MacBook. So, I'm on MacBook and if I
want to uh use this image on a VPS,
those are typically going to be using
Linux AMD 64 chips. However, on MacBook,
I have a different chip. So, in that
case, you may want to specify that
option. I have another option here
basically to give it a tag or name and
I'm deliberate about this. So, I'm
calling it G this weird. So, I'm calling
it ghcr.io.
This is the GitHub container registry.
So in this example, we're first going to
push this image to GitHub containers
registry and then from the VPS, we're
going to pull it from that registry. So
that's why I'm giving it this name and
this is my GitHub name. So I'm calling
it so it's it's my GitHub name here and
then I can just give it any name. So I'm
calling it next 16 docker for the actual
image name and then I'm giving like a
version. Instead of doing this terminal
command, we could also create a docker
compose file. This can be useful if you
have other things besides the next.js s
app as well like a database or other
services that you want to run uh
together basically. I'll show you that a
bit later. Let's go ahead with this
example first. I'm going to press enter
here and it's going to create a docker
image out of this. This may take a few
minutes because it's going to pull
everything together into one big package
you could say so that we can run the
nextjs app everywhere we want. All
right. So after a few minutes my docker
image has been created. Where can I see
that? You can see it here in the docker
desktop application. You can see I now
have one image here with that name I
gave it. If we actually want to run our
nextjs app we can from this image we can
click on run here. So this will create
an actual instance or what's called a
container and we have some options here.
You can give it a name. Now internally
that next JS app remember it's typically
running on port 3000. That will be
internally in the container. If we want
to access it still on localhost 3000 on
our computer outside the container I can
add this here. And we have some other um
options here but I will just click on
run. Okay. So now you can see the
familiar next.js logging. If I now go to
localhost 2000 you can see I have my
next js app right here. Everything is
still working. However this is using
that docker image right. So this is the
dockerized application uh running
locally on my own computer now. But now
we actually will talk about getting this
to run on a VPS. So I will go ahead and
delete this. But I still have my image
right here. Right. So I want to get that
image onto the VPS. Now I'm first going
to put it on the GitHub container
registry here under the packages. This
is also something you see for mpm
packages. So and then from the VPS we
will pull it from here. This is not the
only way of doing it but I find it a bit
easier to do it this way. So I need to
push it to this GitHub container
registry. So if I go to my terminal here
again start pushing things. I first need
to authenticate myself with that
container registry. So I can say docker
login and which registry? Well it's
githubcontainer registry.io. IO I need
to provide my username. This is my
username on GitHub. And then it asks me
for a password. I'm going to create a
personal access token to get access. So
it's very easily created here in
settings. If I scroll down here to
developer settings, there is an option
here for personal access tokens. I I
actually like the classic tokens. So I
will click on generate new token uh for
the classic way. I will call tutorial. I
like a short expiration date. And here
we can pick the scopes. So what do what
does somebody with this token get access
to? Well, it's this uh packages scope,
right? So here, right? So that is what I
need, nothing else. So I will just go
ahead and generate this. Now, make sure
you don't show it to anyone else. I will
delete it after recording the video, but
uh you may want to store it somewhere
because later from the VPS, we also need
to log in so we can actually get access.
So I for the time being, I will actually
just put it in av file here. Okay, you
can copy that and paste that right here
and then it should work. So I went ahead
and logged in. All right. So now we can
push to that registry. So we can say
docker push and which image? Well, it's
this one that we just created. So you
need to get the name here. Uh if you
double click on it, you will see the
name right here. So let me copy this.
And let's see if this works. All right.
So it's going to try pushing to the
registry. And that looks good. Now if I
go to my profile and I go to packages,
if I scroll all the way down, you can
see I have next 16 Docker. So now it's
time to pick a VPS. Now, like I said,
I'm going to use Hostinger. They're
sponsoring today's video, but I had a
great time using them. They actually
have an amazing Black Friday sale as of
recording, so check out the link in the
description. Now, why go with Hostinger?
Well, I had a great time using them, but
they actually have an amazing new
feature here called the Docker Manager.
I will show you how to use this in a
bit. We can use Docker Compose, but
basically with this option, you don't
even have to build the Docker image
locally yourself first. we can actually
just provide a docker compose file and
we just give that file to hostinger and
hostinger will create the docker
containers on the VPS for us. Really
powerful and it makes deploying with
docker even easier on their VPS. So I
think this is a real good reason to go
with their VPS. Now if we take a look at
their pricing here. So I'm going to go
with the KVM2 plan. I've used it many
times. I've als I've always had a good
experience. But if you already
anticipate that you will need a little
bit more power, go ahead and pick one of
these more powerful plans. Now, I'm
going to go with this one in the video.
Now, on the checkout page, there is an
option here for coupon codes. Make sure
to use my coupon code, which is all
uppercase bite grat. If we apply it, you
will see that we can get an even better
price. So, look at this price. Really
amazing for what you get. Check out the
link in description and make sure to use
my coupon code all uppercase by grat.
Now, you also have an option here for
daily auto backup. We can pick the
server location. Now here we have the
select operating system. If you search
for Docker here, they already have a
template here out of the box for Docker.
So I will just confirm this. So if you
pick that one, you don't have to
manually install that. All right. So
let's actually uh check out. All right.
After check out, we can pick a password
for the VPS. It's good to uh pick a
password that you'll remember. All
right. I'll click on next here. I'll
just go with the default options here.
And now it's going to provision the
resources for me. This may just take a
few minutes. All right. And after a few
minutes, it is ready to go. Let's go to
manage VPS. And when you go there, you
will see the dashboard here in Hostinger
for your VPS that you just purchased. So
you can see here it's an Ubuntu
operating system. And we have some
options here for the VPS itself. But it
has come with an application here called
Docker. Okay. So I will show you more
about this in a bit later as well
because they have Docker Manager. Really
amazing. We do not have to build our
Docker image locally. We can just add
the URL to the docker compos file and it
will build it for us here. But I'll show
you that after because maybe uh you do
want to build it locally or in your own
pipeline. What next? If you have your
image on the container registry, how do
we get it on here? So we can SSH into
our PPS, but they also have a terminal
here. So if you go to the terminal, we
have a terminal in here as well. So
maybe you you prefer using that or maybe
you do prefer running your own terminal.
So here I have my own terminal here on
my MacBook. On Windows you have
PowerShell and we can log into the VPS
from here as well. We just have to do
SSH root and then the IP of the VPS. So
it will ask me something about a
fingerprint. I will say yes. And now
it's a password. So here we need to add
the password that we just used to set up
the VPS. All right. And once you do
that, you should be logged in here. Let
me clear this out. This is a VPS
template that comes with Docker out of
the box. So if I type docker-v, you can
see docker is already installed because
I see a version here. If you do not see
that, if you see an error, then docker
is probably not installed. Another thing
to check is to run a simple uh image
here called hello world. This is an
image. This is a docker image that
docker actually provides to quickly
check if everything works. So if I do
docker run hello world, it will not be
able to find it locally. So it will
actually download it onto the VPS and
then it will immediately run the image
as well. basically create a container
out of it. And now you can see hello
from docker. This message shows that
your installation appears to be working
correctly. So that is good news. I can
clear this out. I can do docker images
to show all the docker images on this
vps. So right now we only have this
hello world that we just did. Now of
course we want to use our own next.js
docker image. So just like before we can
log into that registry. So we can say
docker login which registry it's
ghcr.io.
I need to use my bite grat GitHub name
and then it's that personal access
token. So not the VPS password. This is
that token that we just set up. Okay. So
I will paste it right there. Okay. So
now I'm logged in. So now we can pull
the image. So I can say docker pool and
we need to use the same name as before.
So it's that full name. So I will
actually just copy this from docker
desktop again and I will paste that
right here. So let's see if this works.
All right. So you can see it's pulling
the image, right? can be pretty
substantial in size cuz it has
everything that our next.js app needs to
run. All right. So now if I clear this
out and run docker images, we can see
that we have two images here including
our own docker image. So now I actually
want to run it on the VBS. So we have
docker run. Now when I run it, I also
want to get back now I can add dash d
here. So when the container actually
runs, I do I can sort of run it in the
background. So I get back control over
my terminal here. And then for the
ports, I want to be able to access it on
port 3000 outside the container. That's
why I have 30,00. But it should map to
internally in the container to port 3000
because that's where the next app will
be running. Okay. And which image do we
want to run? Well, it's this one. So I
will just use this name again and let's
see what we get. All right. So you can
see we get some identifier here. But it
should be running now. So if I do docker
ps, it will show me the running
containers. So you can see there is one
here that the text wraps but you can see
there's one container here and that is
based on that image that we on based on
our image. So now how can I see this?
Well here in the hostinger VPS well we
can use the IP address here from the
hosting or VPS and remember it's port
3000. So if we go there well we have not
set up HTTPS yet so you may get an issue
here but if we continue we can see that
we now have our next application running
on a VPS. And now let's see if it still
works. So if I invoke a server action
that still works. If I invoke the route
handler also still works. If I go to the
test page you can see navigation here
works as well. The next JS image
component works here as well. So
everything seems to be working. So
really cool and we have all the settings
here for our VPS. Ideally of course we
also have a custom domain name so the
users don't have to type in this series
of numbers. And ideally we can also add
a CDN in front. So for example uh the
static assets can be served really fast.
So, how can we make this a more
production-like environment? Before we
do that, I want to show you the other
way that we can uh deploy a Docker app
here on Hostinger's VPS, which is with
their new Docker manager. This is really
amazing uh because it means that we do
not have to build our Docker image
locally ourselves and then sort of
awkwardly first move it to some registry
and then pull it onto the VPS with a
bunch of terminal commands. Instead, we
can just provide it with a docker
compose file and hostinger will take
care of everything else. It's really
slick. So, let's check out that method
of deploying a docker app here. So, I
will actually re reset the VPS here just
to start from a clean slate here. So, I
can go to OS and panel here, operating
system. So, here we have what we
currently have. So, this is what I use
just to experiment here. Um, but if you
have important data, you want to back
that up first. So let's go ahead and
reinstall here. Provide my VPS password
and I will click on confirm. All right.
So it's now recreating my VPS. This may
take a few minutes. All right. So let's
talk about the alternative that you have
in terms of dockerizing next.js and
deploying it. So previously we had only
one docker file and to create an image
out of this we ran a uh terminal
command, right? So this is the first
option. The second option is to manage
this with docker compose. This is
helpful especially if you have multiple
services. So a database for example or
like traffic like a reverse proxy other
services. It makes it easier to
orchestrate essentially your setup. So
let's actually see how that would work.
So I can add docker compose here and
it's a yl file. So it's yl and then in
here you describe what you want to set
up. So in this case we have one web
service. This is going to be our next js
app. Um the docker image should be built
from this docker file. So we will still
have the instructions for creating this
one docker image out of this in here.
It's just that we sort of orchestrated
from docker compose now. So the build
will still happen from this docker file.
And what are the ports that we want to
use? Well, let's just start with
localhost 3000 on our computer should
map to the port 3000 inside the
container. We have some environment
variables and a restart option here. So
now I you can see my IDE already allows
me to run it, but let's actually use a
terminal command for that. And so now um
let's actually try it locally here. So I
can actually just run all services. My
IDE gives me this option. And actually
you can also run it. You can run it in
your own terminal command as well. So
it's docker compose up and then you can
specify some options if you want. So now
it's going to create a docker image
again because that is what we specified.
You can see you can see the out you saw
the output there. Okay. So now if I now
go to localhost 3000 on my computer, you
can see here we have our app again.
Everything here is still working. This
is one way of doing it. If I go to
docker desktop, you can see I actually
have two images now, right? And now I
could add a database here or other
services, but we want to deploy it to a
VPS. Now the cool thing is with
hostinger, if you have the VPS and you
have docker here, they have docker
manager. So the only thing we have to
provide is actually this docker compose
file. So I don't have to build docker
images on my own computer first. Right?
So now I have two as you can see. I can
actually go ahead and delete those. Let
me actually delete them. actually have
to remove have to delete the containers
first and then I can delete this one as
well. So now I have no Docker images on
my own computer. I'm just going to push
my code to GitHub, right? So you may
already have a repository. Now it will
work with private repos as well, but let
me actually start off by showing you how
it works with public repos. It's a bit
easier. Be careful cuz other people can
see your code with a public repo. Push
to GitHub here. Okay, so now I I pasted
everything. And now if we refresh here,
this is my repo here on GitHub including
the docker file and the docker compose
file right here. So I have my docker
compose file here. So now I can go to
docker manager on my vps. Now here I can
compose from URL. So I just have to
specify the URL of the docker compose
file. So if I just uh go here and copy
this and paste this right here. Here we
have a pro. It will automatically
prefill the docker the project name.
Then I can click on deploy and it will
actually deploy my project for me. So we
just have to wait a few seconds. All
right. And after a few seconds it is
finished and this is what I see now. So
it has one docker container running
here. If I open this up I have my next
chest. All right. And after a few
seconds it is finished creating a docker
container here. Now we can actually go
there directly. If I go there you can
see my application here right on the VPS
right. And actually let's try it out.
Everything here is still working. If I
go to test page, I can still navigate
the image component still working. And
so this container is running based on an
image not that not the one that I
actually uh you know pushed first to a
registry and then onto the VPS. I only
had to provide this docker compose file
and it was able to go from there. So if
we click on manage here, you will see
some uh options here including a visual
editor. So there is one container here
in this project, right? So it has
specified a port here. How does it know
that? That's what we specify here in the
docker compose file. Right? There is the
actual YAML uh file here in here as
well. So if you want to change this, I
could do it from here. Right? So we will
actually change it in a bit. I can see
uh the logs here as well. So you can see
right now there is Nex.js running here
on localhost 3000 inside the container.
Okay. So this is a much easier way to
get a Docker based application up and
running on a VPS. So well done to the
Hostinger team.
All right. So we ideally also can have a
custom domain and HTTPS and a CDN in
front. So let's see how we can do
something like that. So once you have
your Docker application actually running
on the VPS, how can we point a custom
domain at this? So you need to go to
your DNS setting for your domain. Now
Hostinger actually provides domains as
well. So that's so I will use my domain
here. Let me actually go here here for
DNS. So I need to point an A record to
the IP of the VPS. So the IP of the VPS
is right this one. And I just point this
A record at it. I will add the record
here. So I do not add a port here,
right? It's just the IP of the VPS. So
now if I try using the domain, it will
not work yet. Okay. So it's just going
to point at the VPS uh IP address. But
you can see uh nothing happening here.
Now if you add port 3000 to it, but here
for me in Chrome, it seems to be acting
up a bit. Um, however, if I try to use
Safari and I go to bygratcourses.com
colon 3000, I actually do see the
application here and everything works
here. So, now we have a custom domain,
but it's using the weird port 3000. Now,
we can fix this here. However, I also
want to show you that a chatbot here
actually is really that is actually
helpful. If I start a new chat here and
I ask this my VPS here. So I can just
talk about what I did and it may make
suggestions here on what I need to
change here in the YAML. So I can ask it
to check the YAML file to check the YAML
code here. So it's actually able to see
the configuration here. So it suggests
changing it to port 80. That's a
standard port here for HTTP, right? So I
can try changing this to port 80 mapping
to 30. So if we do that and then deploy
again. All right. So project is
deployed. Now you can see the container
is running like this. So everything here
is still working. Now if I use my custom
domaincourses.com,
it for some reason still does not work
in Chrome here for me. All right. Now if
I close everything in Chrome and just
restart the browser and then go
tocourses.com,
it actually works for me here now as
well. Cool. So now I have a custom
domain pointing at my VPS that is
running NexJS in a Docker container. You
can create a Docker image yourself or
you can use Hostinger's uh Docker
manager. Really slick experience. So
this is already really cool, but of
course we also want to have HTTPS and a
CDN. So for the HTTPS, let's ask the
chatbot again. You can als you you can
also add chatbt your other AI uh
solutions. But let's say I want to add
HTTPS to this container as well. What
should I change? Yeah, it's nice that
it's integrated here that can
immediately read the content here. So it
actually suggests adding something here
to the docker compose file to include a
refers proxy containers like caddy or
engine X or traffic actually. All right.
So, it has given me a suggestion here on
how to a refer proxy as it's called so
that we can add HTTPS. There's probably
ways to fine-tune this or make it
better, but so you can add your own
email here. Yeah, let's just go ahead
and try this out. So, make sure that you
verify that it does what you want,
right? I'm just experimenting here, but
if it's a serious project, of course,
you want to ver you want to double check
everything. I will just go ahead and
deploy here. All right. So, after a few
seconds, we can see we now have two
containers here in this project. So we
have our own uh we have the actual NexJS
app but now also this reverse proxy in
front. Remember the custom domain is
still pointing to this VPS. If I go to
bite courses now you can see I have
https. Cool. So now if I click
everything still works. So now we have
custom domain with https. Now if it's
not working for you in chrome I find you
try opening up a new window here or
closing all windows and create a new
instance of chrome because I think there
there may be some caching. I don't know
exactly why. Uh sometimes it doesn't
seem to work or maybe try a new browser
like Safari or Firefox, but that's how I
got it to work. All right, so now we
want to add a CDN in front as well. I'm
going to use Cloudflare for that. So
Hostinger actually has their own CDN as
well, but they mention it's not
available on VPS. So they do point to
Cloudflare as an alternative here. So
this is not a strange setup. This is
actually something they point towards.
So here in the Cloudflare dashboard, I
can add a new domain. So I will just add
bitegrantcourses.com.
It will do a quick scan of the DNS
records. They actually have an option
here for AI crawlers. I do not want to
block them. I will just continue here
and I will go with the free plan here.
It will give me uh DOS. It will give me
some DOS protection, a global CDN and
many other things here as well. So I
will just go with that. All right. So
now we need to actually uh update the
name server. So we need to go into our
DNS provider. For me that was uh for me
that is hostinger and they have some
guides for that. So right so but I will
just show you how to do it here. So here
for domains I can go to my domain for
bygrad courses and here I can change
under DNS I can change name server. So
by default is of course the hostinger
domain servers but I want to copy these
now and replace those. Okay. So this one
as well. So now I have the cloudflare
name servers. So I can save here and the
name servers have now been changed. If I
now go to Cloudflare, there's a button
here for check name servers now. But it
may actually take some time in my
experience before this has actually
updated here in Cloudflare. All right.
So after about 10 or 15 minutes, it
became active for me. So what actually
happens now if I go to my site here?
Well, I still see my app and everything
here is working. But how do we know this
is actually going through Cloudflare?
Well, if I refresh here and if I click
on some of these, you should see in the
response headers something with
Cloudflare. So, you can see actually
this JavaScript file, it has a CA
Cloudflare cache status of hit. So, this
actually came from Cloudflare's uh CDN.
It will even show you the data center
from which it came from. So, this file
seems to have come from Cloudflare. If
you do not see these headers, it's
probably not coming through Cloudflare.
And another way to check it is to add
this to the path here. to slash CDN
CGI/trace,
it will give you um some tracing info
from Cloudflare as well. So, that's
another way to check. Now, if it's not
working for you, what I found actually
in Chrome, there may be some caching.
I'm not not exactly sure what's going
on. Um you may want to open a new window
or close everything and restart Chrome
and try again or clear every all the
data and then try again. And you also
want to try in different uh browsers
like Safari or uh Firefox. But for me,
it seems to work. uh and HTTPS and
everything you know seems to keep
working but you have the option here to
change uh some things about that. So by
default I believe so I have the setting
here set to full but they will also show
you the traffic they serve over that
right. So there are settings that we can
specify here in cloudflare as well. So
there you go we have dockrise nextjs put
it on a VPS added custom domain https
and a CDN in front. So I hope this video
was helpful for you. Let me know. So
make sure to check out Hostinger's VPS
with the link in description and my
coupon code bite grant all uppercase.
Then I hope this video was helpful for
you. Thank you for watching and I hope
to see you in the next one. Bye.
COMPLETE GUIDE for self-hosting Next.js 16 with Docker & custom domain, SSL / TLS, CDN (Cloudflare). š Hostinger HUGE Black Friday Sale (use code BYTEGRAD): https://hostinger.com/bytegrad (sponsored by Hostinger & ByteGrad gets commission) š React & Next.js Course: https://bytegrad.com/courses/professional-react-nextjs Hi, I'm Wesley. I'm a brand ambassador for Kinde (paid sponsorship). š Kinde $50 credit for auth and more https://kinde.com/r?kinde_ref=e95bc6f8f17eda7c š Work with me: support@bytegrad.com š React & Next.js Course: https://bytegrad.com/courses/professional-react-nextjs š Professional JavaScript Course: https://bytegrad.com/courses/professional-javascript š Professional CSS Course: https://bytegrad.com/courses/professional-css š Web development roadmap 2024 & 2025: https://email.bytegrad.com š Email newsletter (BIG update soon): https://email.bytegrad.com š Discord: all my courses have a private Discord ā±ļø Timestamps: 00:00 Intro 01:15 Next.js app example 02:04 2 options for deploying Docker app 02:54 Option 1 - Build Docker image locally 03:19 Dockerfile and .dockerignore 04:46 Docker Desktop 05:25 docker build (terminal command) 07:23 Run container 08:12 Push to registry (ghcr.io) 10:09 VPS (Hostinger) 12:34 ssh & pull image 14:51 Run container on VPS 15:55 App demo on VPS 16:40 Option 2 - Reset for Docker Manager 17:41 Docker Compose (docker-compose.yml) 19:55 Push to GitHub 20:19 Deploy with docker-compose.yml & Docker Manager 22:04 Private repo 22:09 Custom domain 24:25 HTTPS / SSL 24:59 Traefik reverse proxy 26:04 CDN with Cloudflare #webdevelopment #reactjs #nextjs Note that my videos may contain mistakes. Always verify yourself that your code is safe and does what you want it to do for your specific situation. You agree by watching the videos that you are solely responsible for any mistakes in your code. This channel and all its content is owned & operated by ByteGrad Sp. z o.o. with Tax ID: PL6762676561 and KRS-number: 0001125554