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

Added Docker #667

Open
wants to merge 11 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
git
.gitignore
.env.example
.env
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DATABASE_URL= ''
DATABASE_URL= 'mysql://mysql:strong_password@localhost:3306/earn'

RESEND_API_KEY= ''
RESEND_EMAIL= '[email protected]'
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:20-alpine

WORKDIR /user/src/app

COPY package.json pnpm-lock.yaml ./

RUN npm install -g pnpm

RUN pnpm install

COPY . .

RUN pnpm prisma generate

EXPOSE 3000

CMD [ "pnpm","run","docker-dev" ]
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
```bash
cd earn
```

### Without Docker
3. Install the dependencies:
```bash
pnpm i
Expand Down Expand Up @@ -63,6 +63,21 @@
```bash
pnpm dev
```
### With Docker
3. Set up your `.env` file.
- Start by copying the `.env.example` file to a new file named `.env`. This file will store your local environment settings.
- Use `openssl rand -base64 32` to generate a key and add it under `NEXTAUTH_SECRET` in the .env file.
- You have to set up resend to run the app:
- [Resend](https://resend.com): To obtain your `RESEND_API_KEY`, visit the Resend dashboard. This credential is essential for setting up Email Auth.

NOTE: If you are facing any issues with setup, feel free to contact [Abhishek](https://twitter.com/abhwshek)

4. Now change the DATABASE_URL='mysql://root:strong_password@db:3306/earn'.

5. Run Docker Compose
```bash
docker compose up
```

## Contributing
We welcome contributions from everyone! Whether it's submitting an issue, a pull request, or suggesting new ideas, your input is highly valued. Check out our [contributing guide](CONTRIBUTING.md) for guidelines on how to proceed.
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
db:
image: mysql
container_name: db
restart: always
environment:
- MYSQL_ROOT_PASSWORD=strong_password
- MYSQL_DATABASE=earn
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-u", "root", "-pstrong_password"]
interval: 30s
timeout: 10s
retries: 5
app:
build: .
container_name: app
env_file:
- .env
ports:
- "3000:3000"
depends_on:
db:
condition: service_healthy

volumes:
mysql_data:
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development next dev",
"docker-dev": "pnpm prisma push db && pnpm run dev",
Copy link
Member

Choose a reason for hiding this comment

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

wrong command; its pnpm prisma db push

i did confirm if you checked once..

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/SuperteamDAO/earn/blob/main/CONTRIBUTING.md#making-a-pull-request
also please check the option for allowing edits from maintainers

Copy link
Author

@ArpitBlagan ArpitBlagan Aug 31, 2024

Choose a reason for hiding this comment

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

wrong command; its pnpm prisma db push

i did confirm if you checked once..

yes, there was a typo.

Copy link
Author

Choose a reason for hiding this comment

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

https://github.com/SuperteamDAO/earn/blob/main/CONTRIBUTING.md#making-a-pull-request also please check the option for allowing edits from maintainers
sorry I am getting confused here if you are talking about
the checkbox for allow edits from maintainers it is already checked.

"build": "prisma generate && next build",
"start": "cross-env NODE_ENV=production next start",
"lint": "next lint",
Expand Down