Skip to content

Commit 9f3e638

Browse files
authored
Merge pull request caprover#1599 from LiquidITGuy/documentation/docker_improve-macos-documentation
Documentation/docker improve macos documentation and add Catalina and above native support
2 parents c3a78ca + d993c1b commit 9f3e638

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

CONTRIBUTING.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,12 @@ The goal is to make the common use-cases exposed via simple controls on UI while
2727
First, you need a Captain instance running in debug mode, this can be a remote server, a VM on your local machine,
2828
or your local machine itself. Needless to say, Docker is required (same minimum version as mentioned in README). Ubuntu is the best dev environment for CapRover.
2929

30-
> Docker for Mac users: You need to add `/captain` to shared paths.
31-
> To do so, click on the Docker icon -> Preferences -> File Sharing and add `/captain`
32-
> This is not possible in Catalina or above versions. You can try your luck by changing `CAPTAIN_BASE_DIRECTORY` in `src/utils/CaptainConstants.ts` and in `dev-scripts/dev-clean-run-as-dev.sh` but it might be best to develop in a linux VM for best results.
33-
3430
Log in to your machine, clone the git repo and run the following lines:
35-
31+
#### On Linux and Windows
3632
```bash
3733
$ npm install
3834
$ npm run build
39-
$ ./dev-scripts/dev-clean-run-as-dev.sh
35+
$ sudo ./dev-scripts/dev-clean-run-as-dev.sh
4036
```
4137

4238
You are good to go! You can run the following line to see the logs for the back-end service.
@@ -45,6 +41,31 @@ You are good to go! You can run the following line to see the logs for the back-
4541
npm run dev
4642
```
4743

44+
#### On macOs
45+
##### Prepare your system (for Catalina and above)
46+
Because of security restriction we have more step to apply on macOs.
47+
Create a folder wherever you want (for me it will be /opt/captain).
48+
Link this folder to the root folder (Apple does not allow to create folder on the root but you can do it with a symb link by adding the file in `/etc/synthetic.conf` [see](https://stackoverflow.com/questions/58396821/what-is-the-proper-way-to-create-a-root-sym-link-in-catalina))
49+
(don't panic id the file does not exist, if you create it will work well.)
50+
1) `sudo vi /etc/synthetic.conf`
51+
2) add `captain opt/captain` into this file (note this is a tab and not a space ((Ctrl-V + Tab) character))
52+
3) reboot
53+
4) Prepare your docker system
54+
55+
##### Prepare your docker (for all macOs User)
56+
57+
> You need to add `/captain` to shared paths.
58+
> To do so, click on the Docker icon -> Preferences -> Ressources -> File Sharing and add `/captain`
59+
60+
#####
61+
use node 14 then
62+
```bash
63+
$ npm install
64+
$ npm run build
65+
$ sudo ./dev-scripts/dev-clean-run-as-dev-macos-step-1.sh
66+
$ ./dev-scripts/dev-clean-run-as-dev-macos-step-2.sh
67+
```
68+
4869
The main differences between the release and debug mode are:
4970

5071
- docker image is created from the local source file, instead of getting pulled from Docker hub
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
if ! [ $(id -u) = 0 ]; then
4+
echo "Must run as sudo or root"
5+
exit 1
6+
fi
7+
8+
# on macos Catalina and above, /captain is a symb link. we cannot remove the folder so we delete all files inside
9+
# rm -rf /captain && mkdir /captain
10+
rm -rf /captain/*
11+
chmod -R 777 /captain/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
if ! [ $(id -u) <> 0 ]; then
4+
echo "Must not be run as sudo or root on macos (macos security) please run the step 1 as root and this step as standard user"
5+
exit 1
6+
fi
7+
8+
docker service rm $(docker service ls -q)
9+
sleep 1
10+
docker secret rm captain-salt
11+
docker build -t captain-debug -f dockerfile-captain.debug .
12+
docker run \
13+
-e "CAPTAIN_IS_DEBUG=1" \
14+
-e "MAIN_NODE_IP_ADDRESS=127.0.0.1" \
15+
-v /var/run/docker.sock:/var/run/docker.sock \
16+
-v /captain:/captain \
17+
-v $(pwd):/usr/src/app captain-debug
18+
sleep 2s
19+
docker service logs captain-captain --follow

0 commit comments

Comments
 (0)