CodeGym /Courses /JAVA 25 SELF /Deploying code to a server

Deploying code to a server

JAVA 25 SELF
Level 10 , Lesson 6
Available

1. Making changes to the code

As I mentioned earlier, software development comes down to making small changes to the code. Millions of programmers have been doing this for decades, which has led to the process being thoroughly debugged, standardised, and formalised in every possible way.

There is a special program for storing code — Git. Git is a distributed version control system. It doesn’t just store code; it tracks all changes to it and helps developers work on projects together without getting in each other’s way 🤝.

With Git, developers can create different versions of a project (branches), keep a complete history of changes, and even return to any moment in the past. It’s like a time machine for code! Git helps merge changes and resolve conflicts, which is why it has become the primary tool for teamwork in modern development. 👩‍💻

2. Building the project

Before you test the project or upload it to a server, you need to build it.

🏗️ Project builds are the process of compiling a project’s source code into executable programs or other runnable formats, often including testing and deployment. This is a key aspect of software development that ensures the program is ready for use.

A build isn’t just compilation, although compilation is often part of the build process. After the build finishes, you may end up with dozens or even hundreds of files that need to be uploaded to various servers.

There are low-level build tools such as:

  • Maven and Gradle — widely used in Java projects for dependency management and project builds.
  • 🐜 Apache Ant — another build tool for Java projects that provides great flexibility for writing build scripts.
  • 🖥️ MSBuild — used to build projects created with Microsoft Visual Studio.
  • ⚙️ Make — a classic build tool that uses a Makefile to define build rules, especially popular in C and C++ projects.
  • 🌐 Webpack — often used to build JavaScript applications, managing dependencies and modules.
  • 📜 Gulp and Grunt — tools that help automate frequently performed tasks in web app development, such as file minification and compiling SCSS to CSS.

There are also high-level build systems. More on them below.

3. CI/CD

🔄 CI/CD (Continuous Integration/Continuous Delivery) is a methodology that entails continuously merging changes from all development branches into the main branch, as well as automatically testing and deploying those changes. This allows teams to quickly detect and fix issues, increasing the efficiency and speed of development.

One of the most widespread, albeit somewhat old-fashioned, CI/CD systems is Jenkins. If you work at a small company, there’s about an 80% chance they use it.

🤖 Jenkins is a popular automation server used for continuous integration and delivery (CI/CD). Jenkins allows you to automate various stages of software development, including building, testing, and deployment, which improves code quality and accelerates the development process.

If you join a large company, there may be five other options to choose from:

  • 🚦 TeamCity — a powerful commercial system from JetBrains. It offers deep integration with various development and testing environments.
  • 📝 GitLab CI — a built-in part of GitLab that provides continuous integration and delivery with configuration via YAML files.
  • ☁️ CircleCI — a cloud CI/CD service that supports automated testing and deployment for many projects.
  • 🦑 Travis CI — one of the first cloud CI services, used in many open-source projects. It integrates well with GitHub.
  • 🎍 Bamboo — a product from Atlassian that integrates closely with other tools from the company, such as Jira and Bitbucket.

You don’t need to know them or be able to operate them — companies typically have DevOps engineers who set up all these processes. You just need to know they exist and understand what’s being discussed if someone mentions Jenkins, CI/CD, or “continuous integration.”

4. Delivering the project to the server

Writing the project isn’t enough — it also has to end up on your server. In general, deploying (deploy) a project to a server is the process of placing and activating a web application on a server so that it is available to users over the internet 🚚.

This process includes transferring the project files to the server, configuring the server environment, databases, and dependencies, as well as configuring network and security settings 😅.

How do you think your code gets to the server? Will someone upload it there? Or maybe you’ll connect over SSH to a remote server, upload a couple of files, and configure everything yourself? Relax: nobody does that anymore. Now there’s Docker.

🐳 Docker is a platform for developing, shipping, and running applications using containers. Docker simplifies creating, deploying, and running applications by packaging them together with all their dependencies and environment into a single compact unit. This ensures environment consistency at every stage: from development to testing and production.

Docker lets you package your project or projects into a Docker container. It’s something like a virtual machine.

And although people on any Docker forum will roast you if you call it a “virtual machine,” you can think of a Docker container as a virtual machine — just a much more lightweight one.

In essence, a Docker container is a kind of “virtual machine”. Virtual machines include a full copy of the operating system, the OS kernel, and virtual hardware, whereas Docker containers share the host kernel and can be lighter and faster .

Deploying a project with Docker greatly simplifies the process, providing speed and reliability. The project is packaged into Docker containers that can be easily moved and run on any system that supports Docker 🚢.

This eliminates problems related to differences in server environments and makes it easy to scale the application by adding or removing containers according to the load. Everyone has switched to Docker — it’s very convenient and very simple.

Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION