Next.js Discord

Discord Forum

Deployment question

Unanswered
Greek Harehound posted this in #help-forum
Open in Discord
Avatar
Greek HarehoundOP
How can I deploy the website without including the source codes with docker?

20 Replies

Avatar
Jersey Wooly
what does your dockerfile looks like actually ?
Avatar
Greek HarehoundOP
I don't have a docker file
I'm just asking
Avatar
Jersey Wooly
Just create your dockerfile and specify which files you are moving to your container (in your case the build folder for Next.js) `

Example :
# Use an official Node.js runtime as a base image
FROM node:14-alpine

# Set the working directory inside the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install dependencies
RUN npm install --production

# Copy the built Next.js application to the container
COPY .next ./.next

# Expose the port that your application will run on
EXPOSE 3000

# Define the command to run your application
CMD ["npm", "start"]
Avatar
Greek HarehoundOP
So i should include the .next and module folders and it will work right?
Avatar
Jersey Wooly
if there is some files you want docker to ignore you can also check to use the .dockerignore file
https://docs.docker.com/language/rust/build-images/#dockerignore-file
Avatar
Greek HarehoundOP
I'm thinking of making a template and selling it and I don't want people to have the source code, do you think this method is good or is there a better method?
Avatar
Jersey Wooly
I mean yeah, since they don't have access to the source code that should be possible but regarding security idk
Avatar
Ray
Avatar
Greek HarehoundOP
thank you ray
Avatar
Greek HarehoundOP
Do I need to include pages and components directory in this example?
Avatar
Ray
wdym?
Avatar
Greek HarehoundOP
I don't want to include source code in VPS
Avatar
Ray
if you build with that dockerfile, it won't include any source code
Avatar
Greek HarehoundOP
I just want to
Use the .next file
and start it
Avatar
Ray
it is
Avatar
Greek HarehoundOP
okay
thank u