Skip to content

Commit

Permalink
Devcontainer (#2429)
Browse files Browse the repository at this point in the history
* added installation script

* shell.nix file

* nix script

* nix flakes

* made script cross-platform

* test

* test

* test

* test

* test

* test

* test

* test

* fix nix flake

* fix

* fix

* fix

* fix

* added dev container for devpods

* fix

* fix

* fix

* fix

* fix

* temp fix

* temp fix

* temp fix

* temp fix

* temp fix

* shell.nix file

* removed nix file

* fix

* docker file

* fix

* fix

* fix

* fix

* made changes

* Update INSTALLATION.md

* Update INSTALLATION.md

* made changes

* Update INSTALLATION.md

* fix docker file
  • Loading branch information
AVtheking authored Nov 23, 2024
1 parent 95152aa commit 92443bb
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use Debian Bookworm as the base image
FROM ubuntu:latest as builder

# Update package list and install dependencies
RUN apt-get update && \
apt-get install -y \
git \
vim \
curl \
gnupg2 \
lsb-release \
ca-certificates

# Install Node.js (latest LTS version) and npm
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs

# Install additional developer tools (optional)
RUN apt-get install -y \
neovim \
gh # GitHub CLI

# Default command (to keep the container running)
CMD ["tail", "-f", "/dev/null"]
36 changes: 36 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "talawa api dev environment",
"dockerComposeFile": "docker-compose.yaml",
"service": "devcontainer",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Settings to apply to the workspace.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"typescript.tsdk": "node_modules/typescript/lib",
"database.host": "mongodb",
"redis.host": "redis-stack-server"
},
// List of extensions to install inside the container
"extensions": [
"dbaeumer.vscode-eslint",
"ms-azuretools.vscode-docker",
"esbenp.prettier-vscode",
"redhat.vscode-yaml"
]
}
},
// Set up forward ports
"forwardPorts": [
4000, // Server port
27017, // MongoDB port
6379 // Redis port
],
// Post-create commands to run after creating the container
"postCreateCommand": "npm install",

// Volumes from docker-compose are already included
"shutdownAction": "stopCompose"
}
34 changes: 34 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
volumes:
- mongodb-data:/data/db

redis-stack-server:
image: redis/redis-stack-server:latest
ports:
- 6379:6379
volumes:
- redis-data:/data

devcontainer:
build:
context: .
dockerfile: Dockerfile
ports:
- "${SERVER_PORT:-4000}:4000"
volumes:
- ../..:/workspaces:cached
depends_on:
- mongodb
- redis-stack-server
environment:
- MONGO_DB_URL=mongodb://mongodb:27017
- REDIS_HOST=redis-stack-server
- REDIS_PORT=6379

volumes:
mongodb-data:
redis-data:
2 changes: 0 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/usr/bin/env sh

# Disable the hooks in CI
[ -n "$CI" ] && exit 0

# Change to the current directory
. "$(dirname -- "$0")/_/husky.sh"

# Checks code for typescript type errors and throws errors if found.
npm run typecheck
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY . .

EXPOSE 4000

CMD ["npm", "run", "dev"]
CMD ["npm", "run", "dev"]
67 changes: 67 additions & 0 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This document provides instructions on how to set up and start a running instanc
- [Install node.js](#install-nodejs)
- [Install TypeScript](#install-typescript)
- [Install Required Packages](#install-required-packages)
- [Installation Using Devpod](#install-using-devpod)
- [Installation Using Docker](#installation-using-docker)
- [Run the Talawa-API Setup](#run-the-talawa-api-setup)
- [Install the Docker Application](#install-the-docker-application)
Expand Down Expand Up @@ -309,6 +310,72 @@ We have created a setup script to make configuring Talawa-API easier.
```
npm run setup
```
# Install Using Devpod
This guide provides a step-by-step guide to setting up a Talawa-Api server using Devpod.
## Setting Up Talawa-Api with Devpod (CLI Version)
1. **Install Devpod CLI**:
- Download and install the Devpod CLI from [Devpod CLI Installation Guide](https://devpod.sh/docs/getting-started/install#optional-install-devpod-cli).
2. **Add a Provider**:
- Use Docker or a compatible provider like Podman or Colima.
- Install Docker from their [official documentation](https://docs.docker.com/engine/install/).
- Add a provider using the CLI by following [this guide](https://devpod.sh/docs/getting-started/quickstart-devpod-cli#add-a-provider).
3. **Create a Workspace**:
- Run the following command in your terminal to start the workspace:
```bash
devpod up https://github.com/PalisadoesFoundation/talawa-api@develop
```
- For more information on creating a workspace, refer to the [Devpod CLI workspace guide](https://devpod.sh/docs/developing-in-workspaces/create-a-workspace#git-repository).
4. **Select Your IDE**:
- To choose your ide refer to [Devpod CLI ide guide](https://devpod.sh/docs/developing-in-workspaces/connect-to-a-workspace#vs-code)
5. **Set Up Talawa-Api**:
- Once your IDE is open and the workspace is ready, set up the environment by running:
```bash
npm run setup
```
- Start the Talawa API server by running:
```bash
npm run dev
```
## Setting Up Talawa-Api with Devpod (GUI Version)
1. **Install Devpod GUI Application**:
- Download and install the Devpod GUI from [Devpod GUI Installation Guide](https://devpod.sh/docs/getting-started/install).
2. **Add a Provider**:
- Use Docker or a compatible provider like Podman or Colima.
- Install Docker from their [official documentation](https://docs.docker.com/engine/install/).
- Add a provider using the GUI app by following [this guide](https://devpod.sh/docs/getting-started/quickstart-vscode#add-a-provider).
3. **Create a Workspace**:
- Open the Devpod GUI application.
- Start a new workspace by entering the following URL in the GUI:
```
https://github.com/PalisadoesFoundation/talawa-api@develop
```
- For more information on starting a workspace in the GUI, refer to [this guide](https://devpod.sh/docs/getting-started/quickstart-vscode#start-a-workspace-with-vs-code).
4. **Select Your IDE**:
- In the Devpod GUI, select your desired IDE from the available options.
5. **Set Up Talawa-Api**:
- Once your IDE is open and the workspace is ready, set up the environment by running:
```bash
npm run setup
```
- Start the Talawa API server by running:
```bash
npm run dev
```
## Install the Docker Application
Expand Down

0 comments on commit 92443bb

Please sign in to comment.