Deployment question
Unanswered
Greek Harehound posted this in #help-forum
Greek HarehoundOP
How can I deploy the website without including the source codes with docker?
20 Replies
Jersey Wooly
what does your dockerfile looks like actually ?
Greek HarehoundOP
I don't have a docker file
I'm just asking
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 :
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"]
Greek HarehoundOP
So i should include the .next and module folders and it will work right?
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
https://docs.docker.com/language/rust/build-images/#dockerignore-file
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?
Jersey Wooly
I mean yeah, since they don't have access to the source code that should be possible but regarding security idk
https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
vercel provided a good example
vercel provided a good example
Greek HarehoundOP
thank you ray
Greek HarehoundOP
Do I need to include pages and components directory in this example?
wdym?
Greek HarehoundOP
I don't want to include source code in VPS
if you build with that dockerfile, it won't include any source code
Greek HarehoundOP
I just want to
Use the .next file
and start it
it is
Greek HarehoundOP
okay
thank u