Skip to content

Commit

Permalink
Merge pull request #39 from chroxify/feature/fdt-126-publish-docker-i…
Browse files Browse the repository at this point in the history
…mage
  • Loading branch information
chroxify committed Mar 8, 2024
2 parents 3acdbf7 + a8c0d17 commit 94bdfcb
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 22 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Docker Image CI

on:
release:
types: [published]
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: chroxify/feedbase

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./apps/web/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
54 changes: 43 additions & 11 deletions apps/docs/self-hosting/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,58 @@ You can find a list of all environment variables and where to find them [here](h

## Installation

1. Clone the Feedbase repository
1. Clone the Feedbase repository.

```bash
git clone https://github.com/chroxify/feedbase.git && cd feedbase
```

2. Create a `.env` file
2. Create a `.env` file.

```bash
cp .env.example apps/web/.env
cp .env.example .env
```

3. Build the Docker image
3. Update the `.env` file with your environment variables.

```bash
docker build -f apps/web/Dockerfile -t feedbase .
```
4. Either run the pre-built Docker image or build and run the Docker image yourself.
<Accordion title="Run using pre-built Docker image (Recommended)">
<Steps>
<Step title="Pull the Docker image">
```bash
docker pull chroxify/feedbase
```
</Step>
<Step title="Run the Docker image">
<Note>If you don't want to run the container in detached mode, you can remove the `-d` flag.</Note>
4. Run the Docker container
```bash
docker run -d --env-file .env -p 3000:3000 chroxify/feedbase
```
</Step>
<Step title="Verify the installation">
If everything went successful, you should be able to see a running Feedbase instance by visiting `http://localhost:3000` in your browser.
</Step>
</Steps>
</Accordion>
```bash
docker run feedbase
```
<Accordion title="Build and run the Docker image">
<Steps>
<Step title="Build the Docker image">
```bash
docker build -f apps/web/Dockerfile -t feedbase .
```
</Step>
<Step title="Run the Docker image">
<Note>If you don't want to run the container in detached mode, you can remove the `-d` flag.</Note>

```bash
docker run -d --env-file .env -p 3000:3000 feedbase
```
</Step>
<Step title="Verify the installation">
If everything went successful, you should be able to see a running Feedbase instance by visiting `http://localhost:3000` in your browser.
</Step>
</Steps>
</Accordion>
11 changes: 5 additions & 6 deletions apps/web/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ export default async function middleware(req: NextRequest) {
const path = url.pathname;

// Get root domain
const rootDomain =
process.env.NODE_ENV === 'development'
? hostname.split('.').slice(-1)[0]
: hostname.split('.').length >= 2
? `${hostname.split('.').slice(-2).join('.')}`
: null;
const rootDomain = hostname.includes('localhost')
? hostname.split('.').slice(-1)[0]
: hostname.split('.').length >= 2
? `${hostname.split('.').slice(-2).join('.')}`
: null;

// If the request is for a custom domain, rewrite to project paths
if (
Expand Down
8 changes: 3 additions & 5 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/** @type {import('next').NextConfig} */

// Supabase url from .env file
if (!process.env.NEXT_PUBLIC_SUPABASE_URL || !process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY) {
throw new Error('Missing env.NEXT_PUBLIC_SUPABASE_URL or env.NEXT_PUBLIC_SUPABASE_ANON_KEY');
let hostPath = ['http', 'localhost', '3000'];
if (process.env.NEXT_PUBLIC_SUPABASE_URL) {
hostPath = process.env.NEXT_PUBLIC_SUPABASE_URL.split(':');
}

const hostPath = process.env.NEXT_PUBLIC_SUPABASE_URL.split(':');

const withPWA = require('next-pwa')({
dest: 'public',
register: true,
Expand Down

0 comments on commit 94bdfcb

Please sign in to comment.