Skip to content

Commit 21fcd6f

Browse files
committed
Initial commit
0 parents  commit 21fcd6f

File tree

10 files changed

+129
-0
lines changed

10 files changed

+129
-0
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# [SYSTEM]
2+
DOMAIN_NAME=your-domain.com
3+
DO_AUTH_TOKEN=XXXXXXXXXXXXXXXXX

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
.env
3+
acme/

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# [starters.dev](https://starters.dev) backend
2+
3+
This repo is used to configure a backend for https://starters.dev in the Cloud (DigitalOcean.com)
4+
5+
## Quickstart
6+
7+
1. Connect to the remote server
8+
9+
```bash
10+
> ssh root@IP_ADDRESS
11+
```
12+
13+
2. Clone this repo
14+
15+
```bash
16+
> git clone https://github.com/starters-dev/starters.dev-backend.git backend
17+
> cd backend
18+
```
19+
20+
3. Fill in `.env` file with your information
21+
22+
```bash
23+
> mv .env.example .env
24+
> nano .env
25+
```
26+
27+
4. Get the service repo (e.g. `nextjs-tailwind-starter`)
28+
29+
```bash
30+
> bash run/get-repo.sh nextjs-tailwind-starter
31+
```
32+
33+
It will fetch the following repo `https://github.com/starters-dev/nextjs-tailwind-starter`
34+
35+
5. Build and run
36+
37+
```bash
38+
> bash run/build.sh
39+
```
40+
41+
It will setup everything, including ACME (https certificates), and will run docker.
42+
43+
## Tips
44+
45+
---
46+
47+
If you'd like to add another service from [starters-dev](https://github.com/starters-dev), create a dedicated `docker-compose.your-service.yml` file and add it to `run/build.sh` and run:
48+
49+
```bash
50+
> bash run/get-repo.sh <service-repo>
51+
```
52+
53+
---
54+
55+
---
56+
57+
You can find example `env` file in the root folder.
58+
59+
`DO_AUTH_TOKEN` is used to generate https certificates against [DigitalOcean](https://digitalocean.com) challenge. You can generate one in the DO Networking dashboard or choose one of the [available providers](https://doc.traefik.io/traefik/https/acme/#providers).
60+
61+
---

docker-compose.nextjs-tailwind.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3.7"
2+
3+
services:
4+
nextjs-tailwind:
5+
build: ../nextjs-tailwind-starter
6+
restart: always
7+
labels:
8+
- "traefik.enable=true"
9+
- "traefik.http.routers.nextjs-tailwind.rule=Host(`nextjs-tailwind.${DOMAIN_NAME}`)"
10+
- "traefik.http.routers.nextjs-tailwind.entryPoints=http"
11+
- "traefik.http.routers.nextjs-tailwind.middlewares=https_redirect"
12+
- "traefik.http.middlewares.https_redirect.redirectscheme.scheme=https"
13+
- "traefik.http.routers.nextjs-tailwind_tls.rule=Host(`nextjs-tailwind.${DOMAIN_NAME}`)"
14+
- "traefik.http.routers.nextjs-tailwind_tls.entryPoints=https"
15+
- "traefik.http.routers.nextjs-tailwind_tls.tls.certresolver=mydnschallenge"

docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: "3.7"
2+
3+
services:
4+
proxy:
5+
image: traefik:latest
6+
command:
7+
- "--api.insecure=true"
8+
- "--providers.docker=true"
9+
- "--providers.docker.exposedbydefault=false"
10+
- "--entrypoints.http.address=:80"
11+
- "--entrypoints.https.address=:443"
12+
- "--certificatesresolvers.mydnschallenge.acme.dnschallenge=true"
13+
- "--certificatesresolvers.mydnschallenge.acme.dnschallenge.provider=digitalocean"
14+
- "--certificatesresolvers.mydnschallenge.acme.email=example@domain.com"
15+
- "--certificatesresolvers.mydnschallenge.acme.storage=/acme.json"
16+
environment:
17+
- DO_AUTH_TOKEN=${DO_AUTH_TOKEN}
18+
ports:
19+
- "80:80"
20+
- "443:443"
21+
- "6969:8080"
22+
volumes:
23+
- /var/run/docker.sock:/var/run/docker.sock
24+
- ./acme/acme.json:/acme.json

run/acme.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DIR=acme
2+
FILE=acme/acme.json
3+
4+
if [ ! -d "$DIR" ]; then
5+
mkdir "$DIR"
6+
fi
7+
8+
if [ ! -f "$FILE" ]; then
9+
touch "$FILE"
10+
chmod 600 "$FILE"
11+
fi

run/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FILES="-f docker-compose.yml -f docker-compose.nextjs-tailwind.yml"
2+
3+
# first setup
4+
sh run/setup.sh
5+
6+
# building containers
7+
docker-compose $FILES build && docker-compose $FILES up -d

run/get-repo.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rm -rf ../$1
2+
git clone https://github.com/starters-dev/$1.git ../$1

run/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bash run/acme.sh

0 commit comments

Comments
 (0)