Skip to content

Commit 74aaca9

Browse files
committed
Simplify local setup
Running the client inside a container makes a lot harder to wire up the whole application. The simplified setup only runs the external services within a container, exposing them to the localhost.
1 parent 5a00c4d commit 74aaca9

14 files changed

+26
-186
lines changed

.env.backend

-5
This file was deleted.

.env.dist

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ JWT_SECRET=Anywhere5=Roast=Drained=Appease=Passion
1010
NEXTAUTH_SECRET=Anywhere5=Roast=Drained=Appease=Passion
1111

1212
GOOGLE_ID=
13-
GOOGLE_SECRET=
13+
GOOGLE_SECRET=
14+
15+
PORT=4000
16+
ALLOWED_ORIGINS=[ "http://localhost:3000", "https://studio.apollographql.com" ]
17+
MONGO_CONNECTION_STRING=mongodb://0.0.0.0:27017/codelibrarydb
18+
DEFAULT_USER_BOOKING_LIMIT=2

Makefile

+7-28
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,21 @@
11
.PHONY: start
2-
start: .env.local clean
2+
start: .env.local npm-install clean
33
docker-compose up -d
44

5-
.PHONY: init-on-mac
6-
init-on-mac: generate-certificates trust-on-mac add-localhost-aliases start
7-
8-
.PHONY: init-on-linux
9-
init-on-linux: generate-certificates trust-on-linux add-localhost-aliases start
10-
11-
.PHONY: generate-certificates
12-
generate-certificates:
13-
docker-compose -f docker-compose.certificates.yml run --rm openssl
14-
15-
.PHONY: trust-on-mac
16-
trust-on-mac:
17-
sudo security add-trusted-cert -d -r trustRoot -k \
18-
/Library/Keychains/System.keychain docker/openssl/certs/root-ca.pem
19-
20-
.PHONY: trust-on-linux
21-
trust-on-linux:
22-
sudo cp docker/openssl/certs/root-ca.pem /usr/share/ca-certificates/root-ca.pem \
23-
&& sudo update-ca-certificates --fresh
5+
start-fullstack: .env.local npm-install clean
6+
docker-compose -f docker-compose.yml -f docker-compose.fullstack.yml up -d
247

258
.env.local:
269
cp .env.dist .env.local
2710

28-
.PHONY: add-localhost-aliases
29-
add-localhost-aliases:
30-
echo "127.0.0.1 codelibrary.dev api.codelibrary.dev client.codelibrary.dev" | sudo tee -a /etc/hosts
31-
3211
.PHONY: health-check
3312
health-check:
34-
sh -c "if [ $(curl -LI http://localhost:3000/api/health-check -o /dev/null -w '%{http_code}\n' -s) == \"200\" ]; then exit 0; fi; exit 1"
13+
@./bin/health-check.sh
3514

3615
.PHONY: clean
3716
clean:
3817
docker-compose down --remove-orphans
3918

40-
.PHONY: npm_install
41-
npm_install:
42-
docker-compose -f docker-compose.helpers.yml run --rm npm install $(package) $(flags)
19+
.PHONY: npm-install
20+
npm-install:
21+
@./bin/install-dependencies.sh
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/sh
22

33
if [ $(curl -LI http://localhost:3000/api/health-check -o /dev/null -w '%{http_code}\n' -s) == "200" ];
4-
then exit 0;
4+
echo "Everything looks fine!"
5+
then exit 0
56
fi;
67

8+
echo "Something went wrong!"
79
exit 1

bin/install-dependencies.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
if [ ! -d "./node_modules/" ]; then
4+
echo "Will start the installation of dependencies..."
5+
npm install
6+
exit $?
7+
fi
8+
9+
echo "Dependencies already installed!"
10+
exit 0

docker-compose.certificates.yml

-10
This file was deleted.

docker-compose.helpers.yml

-11
This file was deleted.

docker-compose.yml

-36
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,6 @@
11
version: '3'
22

33
services:
4-
proxy:
5-
image: caddy:latest
6-
container_name: app_proxy
7-
volumes:
8-
- ./docker/caddy/Caddyfile:/etc/caddy/Caddyfile
9-
- ./docker/openssl/certs:/etc/caddy/certs
10-
networks:
11-
codelibrary_network:
12-
aliases:
13-
- 'api.codelibrary.dev'
14-
- 'client.codelibrary.dev'
15-
extra_hosts:
16-
- 'api.codelibrary.dev:127.0.0.1'
17-
- 'client.codelibrary.dev:127.0.0.1'
18-
ports:
19-
- '80:80'
20-
- '443:443'
21-
client:
22-
build:
23-
context: .
24-
target: development
25-
restart: always
26-
container_name: app_client
27-
volumes:
28-
- .:/app
29-
ports:
30-
- 3000:3000
31-
networks:
32-
- codelibrary_network
33-
depends_on:
34-
- api
35-
environment:
36-
- APP_ENV=docker
37-
env_file:
38-
- .env.local
394
mongo:
405
image: mongo
416
container_name: app_db
@@ -53,7 +18,6 @@ services:
5318
- 4000:4000
5419
env_file:
5520
- .env.local
56-
- .env.backend
5721
depends_on:
5822
- mongo
5923

docker/backend/.env.backend

-5
This file was deleted.

docker/caddy/Caddyfile

-13
This file was deleted.

docker/npm/Dockerfile

-9
This file was deleted.

docker/openssl/Dockerfile

-12
This file was deleted.

docker/openssl/config/ssl.conf

-32
This file was deleted.

docker/openssl/generate-certificate.sh

-23
This file was deleted.

0 commit comments

Comments
 (0)