Skip to content

Commit

Permalink
Merge pull request #44 from diegonicacio/docker-local-build
Browse files Browse the repository at this point in the history
Local docker configuration build + documentation 📝
  • Loading branch information
NayamAmarshe committed Apr 9, 2023
2 parents 2a04fa7 + a5b470a commit 3326667
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
# push: ${{ github.event_name != 'pull_request' }}
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ FROM node:16-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

COPY . ./
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
Expand Down Expand Up @@ -38,5 +37,6 @@ COPY --chown=node --from=builder /app/node_modules ./node_modules

USER node
EXPOSE 3000
ENV NEXT_TELEMETRY_DISABLED 1

CMD ["npm run", "start"]
CMD ["npm", "run", "start"]
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ New Features

## Self Hosting

**PREPARE**

MagLit uses Firebase Firestore as a database. You must first create a new Firebase project, then a file with the name `.env.local` in root directory of the project and fill the details as mentioned in `.env.local.example`.

This step is a **hard requeriment** and any change to this file, **requires a rebuild to the project from scratch** (either through npm install/npm run dev or by using the docker steps)

Clone the project and install dependencies using:

```bash
Expand All @@ -50,23 +56,16 @@ npm run dev
**DOCKER:**

```
# TO BUILD IMAGE
npm run build-docker-image
# TO START THE DOCKER IMAGE SERVER
npm run start-docker-image
# BUILD AND RUN IMAGE USING NPM
npm run docker
```

You can also use a pre-built image (supports amd64 and arm64), which contains the code that resides on `main`:
OR

```
docker pull ghcr.io/nayamamarshe/maglit:main
```

The `docker-compose` file is setup to use the remote image. Just remember to fill the firebase environment variables. You can start using docker compose with:

```
docker compose up -d
# MANUALLY BUILD AND RUN IMAGE USING COMPOSE
sudo docker-compose build
sudo docker-compose up -d
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Expand All @@ -77,8 +76,6 @@ You can start editing the page by modifying `pages/index.js`. The page auto-upda

The `pages/api` directory is mapped to `/api/*`. Read more about [API routes](https://nextjs.org/docs/api-routes/introduction).

MagLit uses Firebase Firestore as a database. You must first create a new Firebase project, then a file with the name `.env.local` in root directory of the project and fill the details as mentioned in `.env.local.example`.

## If you like the project

ETH (ERC-20) Wallet: **0x14858f5334ea1014e68212c2d4b32792d137f256**
Expand Down
19 changes: 7 additions & 12 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
version: "3.9"
services:
maglit:
image: ghcr.io/nayamamarshe/maglit:main
image: local/maglit:latest
build:
context: .
target: runner
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
NEXT_PUBLIC_BASE_URL: "http://localhost.com:3000/"
#Firebase configs below
API_KEY: ""
AUTH_DOMAIN: ""
PROJECT_ID: ""
STORAGE_BUCKET: ""
MESSAGING_SENDER_ID: ""
APP_ID: ""
MEASUREMENT_ID: ""

env_file:
- .env.local
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"build-docker-image": "sudo docker build -t maglit .",
"start-docker-image": "sudo docker run -p 3000:3000 maglit"
"docker": "sudo docker-compose build && sudo docker-compose up -d"
},
"dependencies": {
"crypto-js": "^4.1.1",
Expand Down

1 comment on commit 3326667

@vercel
Copy link

@vercel vercel bot commented on 3326667 Apr 9, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.