Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devcontainer #2429

Open
wants to merge 53 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
fb46cd9
added installation script
AVtheking Jun 11, 2024
5e5b3ba
Merge branch 'PalisadoesFoundation:develop' into develop
AVtheking Jul 5, 2024
94483db
shell.nix file
AVtheking Jul 5, 2024
0d85405
nix script
AVtheking Jul 6, 2024
3453a01
nix flakes
AVtheking Jul 7, 2024
63db829
Merge branch 'develop' into nix-script
AVtheking Jul 7, 2024
5af03b9
made script cross-platform
AVtheking Jul 15, 2024
30a60c3
test
AVtheking Jul 21, 2024
37ebcd9
test
AVtheking Jul 21, 2024
294c279
test
AVtheking Jul 21, 2024
ea8bbfd
test
AVtheking Jul 21, 2024
c1efe35
test
AVtheking Jul 21, 2024
0711a90
test
AVtheking Jul 21, 2024
cd64b9b
test
AVtheking Jul 21, 2024
978aa6e
test
AVtheking Jul 21, 2024
af49f26
fix nix flake
AVtheking Jul 21, 2024
3e62b40
fix
AVtheking Jul 21, 2024
c2f0029
fix
AVtheking Jul 21, 2024
a0d736d
fix
AVtheking Jul 21, 2024
a35e64f
Merge branch 'develop' into nix-script
AVtheking Jul 21, 2024
2e82058
fix
AVtheking Jul 28, 2024
56a7770
added dev container for devpods
AVtheking Aug 1, 2024
ffb745a
fix
AVtheking Aug 2, 2024
9a9f2c6
fix
AVtheking Aug 2, 2024
72ce9a1
fix
AVtheking Aug 2, 2024
b0a99c8
fix
AVtheking Aug 2, 2024
4765b00
fix
AVtheking Aug 2, 2024
6a7f6d4
temp fix
AVtheking Aug 2, 2024
6600ce2
temp fix
AVtheking Aug 2, 2024
63dcde3
temp fix
AVtheking Aug 2, 2024
034a06b
temp fix
AVtheking Aug 2, 2024
a69ed74
temp fix
AVtheking Aug 2, 2024
f84ec55
Merge branch 'PalisadoesFoundation:develop' into develop
AVtheking Aug 2, 2024
64d8f7d
shell.nix file
AVtheking Jul 5, 2024
682fdff
Merge branch 'develop' into devcontainer
AVtheking Aug 2, 2024
ac0ebee
removed nix file
AVtheking Aug 2, 2024
91b90fc
fix
AVtheking Aug 2, 2024
6faf0c7
docker file
AVtheking Aug 4, 2024
7023c8d
fix
AVtheking Aug 4, 2024
6723695
fix
AVtheking Aug 4, 2024
48d2845
fix
AVtheking Aug 4, 2024
413dc84
fix
AVtheking Aug 7, 2024
6c08aa4
made changes
AVtheking Aug 19, 2024
36b1820
Merge branch 'develop' into devcontainer
AVtheking Aug 19, 2024
a4872ac
Update INSTALLATION.md
AVtheking Aug 25, 2024
8709207
Merge pull request #1 from AVtheking/develop
AVtheking Aug 25, 2024
bf8b54b
Merge branch 'develop' into devcontainer
AVtheking Aug 25, 2024
fd7b6f7
Update INSTALLATION.md
AVtheking Aug 28, 2024
b283c70
made changes
AVtheking Aug 28, 2024
2f0bf4c
Merge branch 'develop' into devcontainer
AVtheking Aug 28, 2024
a412dd4
Merge branch 'develop' into devcontainer
AVtheking Aug 30, 2024
6cc696a
Update INSTALLATION.md
AVtheking Aug 31, 2024
b868a11
fix docker file
AVtheking Aug 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 debian:bookworm 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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you utilize the already existing docker-compose.dev.yaml file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was using the compose file outside the .decontainer.json file it was having some issues related to the project directory, that's why I used the file inside it. If I move the already existing file to that folder, developers can have issues, if they use docker for db.

"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
Comment on lines +2 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify a version for the MongoDB image.

Using the latest tag can introduce breaking changes unexpectedly. It is recommended to specify a version to ensure stability.

    image: mongo:6.0


redis-stack-server:
image: redis/redis-stack-server:latest
ports:
- 6379:6379
volumes:
- redis-data:/data
Comment on lines +9 to +14
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify a version for the Redis Stack Server image.

Using the latest tag can introduce breaking changes unexpectedly. It is recommended to specify a version to ensure stability.

    image: redis/redis-stack-server:6.2.6


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"]
12 changes: 12 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)
AVtheking marked this conversation as resolved.
Show resolved Hide resolved
- [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 @@ -288,6 +289,17 @@ 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.

Follow these steps:

1. Install the Devpod GUI application or Devpod CLI. [Learn more](https://devpod.sh/docs/getting-started/install)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method independent of installing node.js and typescript as prerequisites? If it is, then it should be its own section. Think of the end user, not everyone is familiar with this technology.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is independent of installing node. js and ts , I didn't get with the point it should be its own section , could you clearify it more ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a section in the table of contents for installing prerequisites. If we need to install different prerequisites depending on whether we use devcontainer or not, then we need the prerequisites section to be split in two for each scenario.

image

2. Add a provider to Devpod. For CLI, see [here](https://devpod.sh/docs/getting-started/quickstart-devpod-cli#add-a-provider) and for the GUI app, see [here](https://devpod.sh/docs/getting-started/quickstart-vscode#add-a-provider). Use Docker which you can install from their [official documentation](https://docs.docker.com/engine/install/) or docker compatible provider like podman, colima(better compatibility with macos).
AVtheking marked this conversation as resolved.
Show resolved Hide resolved
3. Run the following command: ```devpod up https://github.com/PalisadoesFoundation/talawa-api@develop```, or follow the instructions for CLI [here](https://devpod.sh/docs/developing-in-workspaces/create-a-workspace#git-repository) and for the GUI app [here](https://devpod.sh/docs/getting-started/quickstart-vscode#start-a-workspace-with-vs-code).
AVtheking marked this conversation as resolved.
Show resolved Hide resolved
4. Select your desired IDE.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user isn't a developer then they won't have an IDE. How will this help? Is there a solution to non-technical users to get the app functional?

More work needs to be done on the instructions. I need to be able to follow the instructions without having to know insider steps

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can have the api running without using ide , but for that it require little bit of change, I did just not spin up the api server using this is for developer as they may want to customize it according to their need.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be clearer. You are assuming the only user will be a developer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest first let us test it for developers, then we can move to the users ease.

5. After completing the above steps, the Talawa API server will be set up in your chosen IDE.
6. Once the IDE is open, run ```npm run setup``` to set up the environment file, or start your server by running ```npm run dev```.

## Install the Docker Application

Expand Down
Loading