This repository contains the code corresponding to an in-depth tutorial available on our YouTube channel, <a href="https://www.youtube.com/@javascriptmastery/videos" target="_blank"><b>JavaScript Mastery</b></a>.
If you prefer visual learning, this is the perfect resource for you. Follow our tutorial to learn how to build projects like these step-by-step in a beginner-friendly manner!
<a href="https://youtu.be/GFgJkfScVNU?feature=shared" target="_blank"><img src="https://github.com/sujatagunale/EasyRead/assets/151519281/1736fca5-a031-4854-8c09-bc110e3bc16d" /></a>
Learn the process of containerizing frontend, backend, and database applications built with diverse tech stacks like React, Vue, Svelte, or any Vite projects. Additionally, it covers examples of the containerization of complete full-stack applications, including MERN setups or the popular Monorepo full-stack applications using Next.js 14+.
This repository contains the corresponding code for all these dockerized applications using the latest Docker features, including docker-compose watch and init.
If you're getting started and need assistance or face any bugs, join our active Discord community with over 27k+ members. It's a place where people help each other out.
<a href="https://discord.com/invite/n6EdbFJ" target="_blank"><img src="https://github.com/sujatagunale/EasyRead/assets/151519281/618f4872-1e10-42da-8213-1d69e486d02e" /></a>
👉 Fundamentals of Docker: Understand the fundamentals of Docker, its purpose, and advantages.
👉 Managing Images and Containers with Docker Compose: Explore Docker Compose for orchestrating multiple images and containers efficiently.
👉 Latest Docker Features: Learn new features such as docker init, docker scout, and docker compose watch for enhanced development workflows.
👉 Working with Volumes: Learn how to use volumes for persistent data management in Docker containers
👉 Port Mapping with Network: Implement port mapping using Docker's networking capabilities
👉 Dockerizing React Applications with Vite: Step-by-step guide on Dockerizing React applications built with Vite.
👉 Dockerizing Vite Applications (Vue or Svelte): Extend the knowledge to Dockerizing Vite applications, supporting Vue or Svelte frameworks.
👉 Dockerizing Full Stack Applications: Dockerize a complete MERN stack application, covering frontend, backend, and database.
👉 Dockerizing Monorepo Full Stack Applications (Next.js 14+): Explore Dockerizing Monorepo full-stack applications using the latest features of Next.js (version 14 and above).
👉 Publishing Docker Images: Learn the steps to publish Docker images, making your applications accessible to a broader audience.
...and much more, covering the best practices and usage of different commands in 🐳
Follow these steps to set up the project locally on your machine.
Prerequisites
Make sure you have the following installed on your machine:
Cloning the Repository
git clone https://github.com/your-username/your-project.git cd your-project
Installation
Install the project dependencies using npm:
npm install
Set Up Environment Variables
For a few specific applications, we require environment variables. I've included a sample .env.example file for these essential projects. However, one crucial element needed for these projects is,
DB_URL=
For full stack applications, we'll be using MongoDB as a database. So do create an account on MongoDB Atlas as well as install MongoDB Compass for creating local database instance for the project.
Running the Project
npm start
Open http://localhost:3000 in your browser to view the project.
Get the starter kits for a few corresponding applications used in the project
</details> <details> <summary><code>react-docker/Dockerfile</code></summary># select the base image to run the app. We want to run a javascript app, so we use the node runtime image from docker hub # we can use any image from docker hub. We can also use a custom image that we have created # node:20-alpine -> node is the image name, 20-alpine is the tag # alpine is a lightweight version of linux # we can see complete list of node image tags here: https://hub.docker.com/_/node FROM node:20-alpine # set the working directory to /app. This is the directory where the commands will be run. We can use any directory name but /app is a standard convention WORKDIR /app # copy everything from the current directory to the PWD (Present Working Directory) inside the container. # First `.` is the path to the current directory on the host machine. Second `.` is the path to the current directory inside the container i.e., source and destination # source - current directory on the host machine # destination - current directory inside the container (/app) COPY . . # commands to run the app CMD node hello.js # build the image # docker build -t hello-docker . # -t -> tag the image with a name # hello-docker -> name of the image # . -> path to the Dockerfile
</details> <details> <summary><code>vite-docker/Dockerfile</code></summary># set the base image to create the image for react app FROM node:20-alpine # create a user with permissions to run the app # -S -> create a system user # -G -> add the user to a group # This is done to avoid running the app as root # If the app is run as root, any vulnerability in the app can be exploited to gain access to the host system # It's a good practice to run the app as a non-root user RUN addgroup app && adduser -S -G app app # set the user to run the app USER app # set the working directory to /app WORKDIR /app # copy package.json and package-lock.json to the working directory # This is done before copying the rest of the files to take advantage of Docker’s cache # If the package.json and package-lock.json files haven’t changed, Docker will use the cached dependencies COPY package*.json ./ # sometimes the ownership of the files in the working directory is changed to root # and thus the app can't access the files and throws an error -> EACCES: permission denied # to avoid this, change the ownership of the files to the root user USER root # change the ownership of the /app directory to the app user # chown -R <user>:<group> <directory> # chown command changes the user and/or group ownership of for given file. RUN chown -R app:app . # change the user back to the app user USER app # install dependencies RUN npm install # copy the rest of the files to the working directory COPY . . # expose port 5173 to tell Docker that the container listens on the specified network ports at runtime EXPOSE 5173 # command to run the app CMD npm run dev
</details> <details> <summary><code>vite-docker/compose.yaml</code></summary># set the base image to create the image for react app FROM node:20-alpine # create a user with permissions to run the app # -S -> create a system user # -G -> add the user to a group # This is done to avoid running the app as root # If the app is run as root, any vulnerability in the app can be exploited to gain access to the host system # It's a good practice to run the app as a non-root user RUN addgroup app && adduser -S -G app app # set the user to run the app USER app # set the working directory to /app WORKDIR /app # copy package.json and package-lock.json to the working directory # This is done before copying the rest of the files to take advantage of Docker’s cache # If the package.json and package-lock.json files haven’t changed, Docker will use the cached dependencies COPY package*.json ./ # sometimes the ownership of the files in the working directory is changed to root # and thus the app can't access the files and throws an error -> EACCES: permission denied # to avoid this, change the ownership of the files to the root user USER root # change the ownership of the /app directory to the app user # chown -R <user>:<group> <directory> # chown command changes the user and/or group ownership of for given file. RUN chown -R app:app . # change the user back to the app user USER app # install dependencies RUN npm install # copy the rest of the files to the working directory COPY . . # expose port 5173 to tell Docker that the container listens on the specified network ports at runtime EXPOSE 5173 # command to run the app CMD npm run dev
</details> <details> <summary><code>mern-docker/frontend/Dockerfile</code></summary># define the services/containers to be run services: # define the application container/service # we can use any name for the service. Here it is `web` # we can create multiple services as well web: # specify the image to build the container from # this can be any image available in docker hub or a custom one or the one we want to build build: # specify the path to the Dockerfile context: . # specify the file name (optional) dockerfile: Dockerfile # specify the port mapping from host to the container # this is similar to the -p flag in `docker run` command # first port is the port on host machine and the second is the port inside the container ports: - 5173:5173 # specify the volumes to mount # what this does is it mounts the current directory to the `/app` directory inside the container. # due to this, any changes made to the files in the current directory will be reflected inside the container. It is similar to the -v flag in `docker run` command. # even if a container is stopped or deleted, volumes are not deleted and can be used by other containers as well. volumes: # over here, we are mounting the current directory to the `/app` directory inside the container (which is the working directory of the container) # syntax is `<path to the directory on host>:<path to the directory inside the container>` # we're doing this because we want to reflect the changes made to the files in the current directory inside the container - .:/app # we also mount the node_modules directory inside the container at /app/node_modules. This is done to avoid installing the node_modules inside the container. # node_modules will be installed on the host machine and mounted inside the container - /app/node_modules
</details> <details> <summary><code>mern-docker/backend/Dockerfile</code></summary>FROM node:20-alpine3.18 # RUN addgroup app && adduser -S -G app app # USER app WORKDIR /app COPY package*.json ./ # USER root # RUN chown -R app:app . # USER app RUN npm install COPY . . EXPOSE 5173 CMD npm run dev
</details> <details> <summary><code>mern-docker/compose.yaml</code></summary>FROM node:20-alpine3.18 RUN addgroup app && adduser -S -G app app USER app WORKDIR /app COPY package*.json ./ # change ownership of the /app directory to the app user USER root # change ownership of the /app directory to the app user # chown -R <user>:<group> <directory> # chown command changes the user and/or group ownership of for given file. RUN chown -R app:app . # change the user back to the app user USER app RUN npm install COPY . . EXPOSE 8000 CMD npm start
# specify the version of docker-compose version: "3.8" # define the services/containers to be run services: # define the frontend service # we can use any name for the service. A standard naming convention is to use "web" for the frontend web: # we use depends_on to specify that service depends on another service # in this case, we specify that the web depends on the api service # this means that the api service will be started before the web service depends_on: - api # specify the build context for the web service # this is the directory where the Dockerfile for the web service is located build: ./frontend # specify the ports to expose for the web service # the first number is the port on the host machine # the second number is the port inside the container ports: - 5173:5173 # specify the environment variables for the web service # these environment variables will be available inside the container environment: VITE_API_URL: http://localhost:8000 # this is for docker compose watch mode # anything mentioned under develop will be watched for changes by docker compose watch and it will perform the action mentioned develop: # we specify the files to watch for changes watch: # it'll watch for changes in package.json and package-lock.json and rebuild the container if there are any changes - path: ./frontend/package.json action: rebuild - path: ./frontend/package-lock.json action: rebuild # it'll watch for changes in the frontend directory and sync the changes with the container real time - path: ./frontend target: /app action: sync # define the api service/container api: # api service depends on the db service so the db service will be started before the
全能AI智能助手,随时解答生活与工作的多样问题
问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。
实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1
科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。
一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型
Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质 量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。
字节跳动发布的AI编程神器IDE
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
AI助力,做PPT更简单!
咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。
选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。
专业的AI公文写作平台,公文写作神器
AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。
OpenAI Agents SDK,助力开发者便捷使用 OpenAI 相关功能。
openai-agents-python 是 OpenAI 推出的一款强大 Python SDK,它为开发者提供了与 OpenAI 模型交互的高效工具,支持工具调用、结果处理、追踪等功能,涵盖多种应用场景,如研究助手、财务研究等,能显著提升开发效率,让开发者更轻松地利用 OpenAI 的技术优势。
最新AI工具、AI资讯
独家AI资源、AI项目落地
微信扫一扫关注公众号