Prerequisites
Before you begin, ensure you have the following installed:
- IntelliJ IDEA (any version)
- Docker Desktop
- Git
Step 1: Create a GitHub Repository
Create a new GitHub repository where you will store your code.
Step 2: Install the CodeLLDB Plugin for IntelliJ
This plugin enables debugging in development containers. Install it via IntelliJ’s plugin manager.
Step 3: Create a devcontainer.json File
In the repository root, create a devcontainer.json file with the following contents:
“`
{
name: My Development Container,
build: {
dockerfile: Dockerfile
},
postBuild: [
npm run setup
],
features: {
debug: {
type: LLDB
}
}
}
“`
Step 4: Create a Dockerfile
Create a Dockerfile in the repository root with the following contents:
“`
FROM amazonlinux:2023
RUN yum update -y
RUN yum install -y gcc make gdb npm
COPY package.json .
COPY yarn.lock .
RUN npm install
CMD npm run start
“`
Step 5: Open the Project in IntelliJ
Clone the repository locally and open it in IntelliJ.
Step 6: Configure the Development Container
In IntelliJ, open the Run menu and select Edit Configurations….
Create a new DevContainer Configuration and select the devcontainer.json file from your repository.
Step 7: Start the Development Container
Run the DevContainer Configuration. IntelliJ will build and start the container.
Step 8: Debug the Code
Set breakpoints in your code and run the Debug action. CodeLLDB will start and you can debug your application within the container.
Conclusion
Using IntelliJ, DevContainers, and Amazon Linux 2023, you can create a powerful local development environment that replicates the production environment. This enables efficient development and debugging, saving time and improving software quality.
Kind regards,
R. Morris