Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve build times using nix container by caching vips build #67

Closed
wants to merge 3 commits into from

Conversation

dbarrosop
Copy link
Member

@dbarrosop dbarrosop commented Apr 27, 2022

This PR adds two improvements for non-nix users:

  1. It uses a docker image with nix and vips already pre-built to build hasura-storage
  2. It adds a make target dev-env-shell that starts the same docker image and gives you a shell. This means you get access to the exact build environment so you can run tests or build the software by hand without having to worry about differences between your environment and the build environment.

@gedw99
Copy link

gedw99 commented Apr 28, 2022

@dbarrosop

Fails at the bottom.

➜  hasura-storage git:(tags/cache-vips-build) make dev-env-shell
docker run --rm -it \
		-v /var/run/docker.sock:/var/run/docker.sock \
		-v /Users/apple/workspace/go/src/github.com/nhost/hasura-storage:/build \
		-w /build \
		--entrypoint sh \
		dbarroso/hasura-storage-builder:latest \
		-c "nix develop .#default"
Unable to find image 'dbarroso/hasura-storage-builder:latest' locally
latest: Pulling from dbarroso/hasura-storage-builder
122fa0945d54: Pulling fs layer 
9d80f7ad1025: Pulling fs layer 
c7e9407e05e0: Pulling fs layer 
e361c336b2b4: Pulling fs layer 
55252331809f: Pulling fs layer 
33407386b8a1: Pulling fs layer 
687866b90415: Pulling fs layer 
92587e11f81c: Pulling fs layer 
19fc97a0d64c: Pulling fs layer 
ff2a32a1a520: Pulling fs layer 
08f0190fe450: Pulling fs layer 
cd76ca680c8e: Pulling fs layer 
791b77547125: Pulling fs layer 
1ab05bf05cad: Pulling fs layer 
ec16b1879ca4: Pulling fs layer 
0f065bf922cf: Pulling fs layer 
56162d66427a: Pulling fs layer 
fb906e383496: Pulling fs layer 
eb063d7330e2: Pulling fs layer 
eda06984a176: Pulling fs layer 
d9f64abd1f13: Pulling fs layer 
3e00387da3c9: Pulling fs layer 
7fc705e3b4ec: Pulling fs layer 
d86ffdbba3d1: Pulling fs layer 
efbf4427b395: Pulling fs layer 
28ad31c6a1fd: Pulling fs layer 
bb408643b6bb: Pulling fs layer 
20724dc7530c: Pulling fs layer 
005bac4ec7bd: Pulling fs layer 
6c2115733c09: Pulling fs layer 
3e896cdfb014: Pulling fs layer 
b2068080ae4c: Pulling fs layer 
5ecefa8d04a5: Pulling fs layer 
422539947288: Pulling fs layer 
441e21c9cc20: Pulling fs layer 
d13945d0a60c: Pulling fs layer 
37686b1cbd68: Pulling fs layer 
c9666f862df0: Pulling fs layer 
8bf19296dde9: Pulling fs layer 
efe55406e1b5: Pulling fs layer 
01d4df855c6e: Pulling fs layer 
165562815726: Pulling fs layer 
de5f07addcfc: Pulling fs layer 
9305e6cf6245: Pulling fs layer 
baf72d2cd1a3: Pulling fs layer 
25b00ea6b7c5: Pulling fs layer 
85ff99b76597: Pulling fs layer 
240aecc8b390: Pulling fs layer 
0173d98b193f: Pulling fs layer 
e2ac6c1e7d35: Pulling fs layer 
4ee3a5fe42a7: Pull complete 
cd236a176e71: Pull complete 
ecd9255e3dbe: Pull complete 
f6c0b550ce33: Pull complete 
b2dbf729148d: Pull complete 
86a430ef3a7c: Pull complete 
df0582c3ad52: Pull complete 
3200c41578f9: Pull complete 
68380d8a0f96: Pull complete 
544521f6a931: Pull complete 
fae397b78a69: Pull complete 
9750c8d05816: Pull complete 
6e7679e24add: Pull complete 
6cbe12817c3a: Pull complete 
16330c47e9d9: Downloading 
a5c24c9feccf: Downloading 
397fb8ba953b: Downloading 
becd82c78b49: Download complete 
d7d6de40aa2c: Download complete 
76565835e846: Download complete 
8879281d4acf: Download complete 
11eb0068d71a: Download complete 
c1a531ee1b97: Download complete 
f4a9d1f69ca3: Download complete 
b3b246306a53: Download complete 
fba982ea7ac7: Download complete 
dfe6b031887c: Download complete 
650ef8a55dba: Download complete 
0b6d9a7309be: Download complete 
d7a42f52ec9e: Download complete 
a46a9911f0dd: Download complete 
fd5e4e75c6ea: Download complete 
adbb5c81ff9a: Download complete 
bf7d4c57601d: Download complete 
d82acb49514f: Download complete 
db47e05cb262: Download complete 
244db4c2d28e: Download complete 
2df58a3ff9b4: Download complete 
f8948fbf38c9: Download complete 
c71d736fcc44: Download complete 
b50627636678: Download complete 
637d5689298e: Download complete 
c28af60cc456: Download complete 
ac0fc9f7d48f: Download complete 
a92c2779883d: Download complete 
b5852211f44b: Download complete 
448b1d058ed3: Download complete 
7e9b3835bb04: Download complete 
553f7b1a42b4: Download complete 
72b3b98817e6: Download complete 
5650d462556e: Download complete 
147ce5c7866e: Download complete 
278bde83838c: Download complete 
docker: dial tcp: lookup registry-1.docker.io on 192.168.5.3:53: read udp 192.168.5.15:41524->192.168.5.3:53: i/o timeout.
See 'docker run --help'.
make: *** [dev-env-shell] Error 125
➜  hasura-storage git:(tags/cache-vips-build) docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
➜  hasura-storage git:(tags/cache-vips-build) colima list
PROFILE    STATUS     ARCH      CPUS    MEMORY    DISK
docker     Running    x86_64    2       2GiB      60GiB

@dbarrosop
Copy link
Member Author

dbarrosop commented Apr 28, 2022

That's an actual issue on your end. I also use colima and I have seen it in the past (abiosoft/colima#137). I solved it by adding --dns 1.1.1.1 (or some other dns) when creating the colima machine.

@gedw99
Copy link

gedw99 commented Apr 30, 2022

thanks @dbarrosop !

1.1.1.1 is what i have configured in my network settings on MacOS.

SO like this ?

colima start docker --dns 1.1.1.1

@gedw99
Copy link

gedw99 commented Apr 30, 2022

mhh something screwy with my setup of colima and docker i think.

If we see anything please let me know ...


➜  ~ colima start docker --dns 1.1.1.1
INFO[0000] using docker runtime                         
INFO[0000] starting colima [profile=docker]             
INFO[0000] already running                               context=vm
INFO[0001] provisioning ...                              context=docker
INFO[0005] starting ...                                  context=docker
INFO[0013] waiting for startup to complete ...           context=docker
INFO[0015] done                                         
➜  ~ pwd
/Users/apple
➜  ~ cd workspace 
➜  workspace cd go
➜  go cd src
➜  src cd github.com 
➜  github.com cd nhost 
➜  nhost ls
cli            hasura-auth    hasura-storage
➜  nhost cd hasura-storage 
➜  hasura-storage git:(tags/cache-vips-build) make dev-env-shell
docker run --rm -it \
		-v /var/run/docker.sock:/var/run/docker.sock \
		-v /Users/apple/workspace/go/src/github.com/nhost/hasura-storage:/build \
		-w /build \
		--entrypoint sh \
		dbarroso/hasura-storage-builder:latest \
		-c "nix develop .#default"
Unable to find image 'dbarroso/hasura-storage-builder:latest' locally
latest: Pulling from dbarroso/hasura-storage-builder
122fa0945d54: Pulling fs layer 
9d80f7ad1025: Pulling fs layer 
c7e9407e05e0: Pulling fs layer 
e361c336b2b4: Waiting 
55252331809f: Waiting 
33407386b8a1: Pulling fs layer 
687866b90415: Pulling fs layer 
92587e11f81c: Pulling fs layer 
19fc97a0d64c: Pulling fs layer 
ff2a32a1a520: Waiting 
08f0190fe450: Waiting 
cd76ca680c8e: Pulling fs layer 
791b77547125: Pulling fs layer 
1ab05bf05cad: Pulling fs layer 
ec16b1879ca4: Pulling fs layer 
0f065bf922cf: Pulling fs layer 
56162d66427a: Pulling fs layer 
fb906e383496: Pulling fs layer 
eb063d7330e2: Pulling fs layer 
eda06984a176: Pulling fs layer 
d9f64abd1f13: Pulling fs layer 
3e00387da3c9: Pulling fs layer 
cd76ca680c8e: Waiting 
d86ffdbba3d1: Pulling fs layer 
efbf4427b395: Pulling fs layer 
28ad31c6a1fd: Pulling fs layer 
bb408643b6bb: Pulling fs layer 
20724dc7530c: Pulling fs layer 
005bac4ec7bd: Pulling fs layer 
6c2115733c09: Pulling fs layer 
3e896cdfb014: Pulling fs layer 
b2068080ae4c: Pulling fs layer 
5ecefa8d04a5: Pulling fs layer 
422539947288: Pulling fs layer 
441e21c9cc20: Pulling fs layer 
791b77547125: Waiting 
37686b1cbd68: Pulling fs layer 
c9666f862df0: Pulling fs layer 
8bf19296dde9: Pulling fs layer 
efe55406e1b5: Pulling fs layer 
01d4df855c6e: Pulling fs layer 
165562815726: Pulling fs layer 
de5f07addcfc: Pulling fs layer 
9305e6cf6245: Pulling fs layer 
baf72d2cd1a3: Pulling fs layer 
25b00ea6b7c5: Pulling fs layer 
1ab05bf05cad: Waiting 
240aecc8b390: Pulling fs layer 
0173d98b193f: Pulling fs layer 
e2ac6c1e7d35: Pulling fs layer 
4ee3a5fe42a7: Pull complete 
cd236a176e71: Pull complete 
ecd9255e3dbe: Pull complete 
f6c0b550ce33: Pull complete 
b2dbf729148d: Pull complete 
86a430ef3a7c: Pull complete 
df0582c3ad52: Downloading 
3200c41578f9: Downloading 
68380d8a0f96: Download complete 
544521f6a931: Downloading 
fae397b78a69: Download complete 
9750c8d05816: Download complete 
6e7679e24add: Download complete 
6cbe12817c3a: Download complete 
16330c47e9d9: Download complete 
a5c24c9feccf: Download complete 
397fb8ba953b: Download complete 
becd82c78b49: Download complete 
d7d6de40aa2c: Download complete 
76565835e846: Download complete 
8879281d4acf: Download complete 
11eb0068d71a: Download complete 
c1a531ee1b97: Download complete 
f4a9d1f69ca3: Download complete 
b3b246306a53: Download complete 
fba982ea7ac7: Download complete 
dfe6b031887c: Download complete 
650ef8a55dba: Download complete 
0b6d9a7309be: Download complete 
d7a42f52ec9e: Download complete 
a46a9911f0dd: Download complete 
fd5e4e75c6ea: Download complete 
adbb5c81ff9a: Download complete 
bf7d4c57601d: Download complete 
d82acb49514f: Download complete 
db47e05cb262: Download complete 
244db4c2d28e: Download complete 
2df58a3ff9b4: Download complete 
f8948fbf38c9: Download complete 
c71d736fcc44: Download complete 
b50627636678: Download complete 
637d5689298e: Download complete 
c28af60cc456: Download complete 
ac0fc9f7d48f: Download complete 
a92c2779883d: Download complete 
b5852211f44b: Download complete 
448b1d058ed3: Download complete 
7e9b3835bb04: Download complete 
553f7b1a42b4: Download complete 
72b3b98817e6: Download complete 
5650d462556e: Download complete 
147ce5c7866e: Download complete 
278bde83838c: Download complete 
docker: dial tcp: lookup registry-1.docker.io on 192.168.5.3:53: read udp 192.168.5.15:57655->192.168.5.3:53: i/o timeout.
See 'docker run --help'.
make: *** [dev-env-shell] Error 125


workspace colima list
PROFILE    STATUS     ARCH      CPUS    MEMORY    DISK
default    Running    x86_64    2       2GiB      60GiB
docker     Running    x86_64    2       2GiB      60GiB
➜  workspace docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
➜  workspace 

@dbarrosop
Copy link
Member Author

not sure if you did already but I'd suggest you to do colima delete before colima start docker --dns 1.1.1.1 but bear in mind that will delete all the images and data in your docker server

@gedw99
Copy link

gedw99 commented May 2, 2022

thanks ! will try now

@dbarrosop

Same error sadly. I think i messed up colima when i deleted the diff file last week, to free up space. I need to clean and reinstall colima and docker perhaps via brew.

hasura-storage git:(tags/cache-vips-build) colima delete
are you sure you want to delete colima and all settings? [y/N] y
INFO[0001] deleting colima                              
INFO[0002] deleting ...                                  context=docker
INFO[0003] deleting ...                                  context=vm
INFO[0003] done                                         
➜  hasura-storage git:(tags/cache-vips-build) colima start docker --dns 1.1.1.1
INFO[0000] using docker runtime                         
INFO[0000] starting colima [profile=docker]             
INFO[0000] already running                               context=vm
INFO[0001] provisioning ...                              context=docker
INFO[0003] starting ...                                  context=docker
INFO[0012] waiting for startup to complete ...           context=docker
INFO[0013] done                                         
➜  hasura-storage git:(tags/cache-vips-build) make dev-env-shell
docker run --rm -it \
		-v /var/run/docker.sock:/var/run/docker.sock \
		-v /Users/apple/workspace/go/src/github.com/nhost/hasura-storage:/build \
		-w /build \
		--entrypoint sh \
		dbarroso/hasura-storage-builder:latest \
		-c "nix develop .#default"
Unable to find image 'dbarroso/hasura-storage-builder:latest' locally
latest: Pulling from dbarroso/hasura-storage-builder
122fa0945d54: Pulling fs layer 
9d80f7ad1025: Pulling fs layer 
c7e9407e05e0: Pulling fs layer 
e361c336b2b4: Pulling fs layer 
55252331809f: Pulling fs layer 
33407386b8a1: Pulling fs layer 
687866b90415: Pulling fs layer 
92587e11f81c: Pulling fs layer 
19fc97a0d64c: Pulling fs layer 
ff2a32a1a520: Pulling fs layer 
08f0190fe450: Pulling fs layer 
cd76ca680c8e: Pulling fs layer 
791b77547125: Pulling fs layer 
1ab05bf05cad: Pulling fs layer 
ec16b1879ca4: Pulling fs layer 
0f065bf922cf: Pulling fs layer 
56162d66427a: Pulling fs layer 
fb906e383496: Pulling fs layer 
eb063d7330e2: Pulling fs layer 
eda06984a176: Pulling fs layer 
d9f64abd1f13: Pulling fs layer 
3e00387da3c9: Pulling fs layer 
7fc705e3b4ec: Pulling fs layer 
d86ffdbba3d1: Pulling fs layer 
efbf4427b395: Pulling fs layer 
28ad31c6a1fd: Pulling fs layer 
bb408643b6bb: Pulling fs layer 
20724dc7530c: Pulling fs layer 
005bac4ec7bd: Pulling fs layer 
6c2115733c09: Pulling fs layer 
3e896cdfb014: Pulling fs layer 
b2068080ae4c: Pulling fs layer 
5ecefa8d04a5: Pulling fs layer 
422539947288: Pulling fs layer 
441e21c9cc20: Pulling fs layer 
d13945d0a60c: Pulling fs layer 
37686b1cbd68: Pulling fs layer 
c9666f862df0: Pulling fs layer 
8bf19296dde9: Pulling fs layer 
efe55406e1b5: Pulling fs layer 
01d4df855c6e: Pulling fs layer 
165562815726: Pulling fs layer 
de5f07addcfc: Pulling fs layer 
9305e6cf6245: Pulling fs layer 
baf72d2cd1a3: Pulling fs layer 
25b00ea6b7c5: Pulling fs layer 
85ff99b76597: Pulling fs layer 
240aecc8b390: Pulling fs layer 
0173d98b193f: Pulling fs layer 
0f065bf922cf: Waiting 
4ee3a5fe42a7: Pull complete 
cd236a176e71: Pull complete 
ecd9255e3dbe: Pull complete 
f6c0b550ce33: Pull complete 
b2dbf729148d: Pull complete 
86a430ef3a7c: Downloading 
df0582c3ad52: Downloading 
3200c41578f9: Downloading 
68380d8a0f96: Download complete 
544521f6a931: Download complete 
fae397b78a69: Download complete 
9750c8d05816: Download complete 
6e7679e24add: Download complete 
6cbe12817c3a: Download complete 
16330c47e9d9: Download complete 
a5c24c9feccf: Download complete 
397fb8ba953b: Download complete 
becd82c78b49: Download complete 
d7d6de40aa2c: Download complete 
76565835e846: Download complete 
8879281d4acf: Download complete 
11eb0068d71a: Download complete 
c1a531ee1b97: Download complete 
f4a9d1f69ca3: Download complete 
b3b246306a53: Download complete 
fba982ea7ac7: Download complete 
dfe6b031887c: Download complete 
650ef8a55dba: Download complete 
0b6d9a7309be: Download complete 
d7a42f52ec9e: Download complete 
a46a9911f0dd: Download complete 
fd5e4e75c6ea: Download complete 
adbb5c81ff9a: Download complete 
bf7d4c57601d: Download complete 
d82acb49514f: Download complete 
db47e05cb262: Download complete 
244db4c2d28e: Download complete 
2df58a3ff9b4: Download complete 
f8948fbf38c9: Download complete 
c71d736fcc44: Download complete 
b50627636678: Download complete 
637d5689298e: Download complete 
c28af60cc456: Download complete 
ac0fc9f7d48f: Download complete 
a92c2779883d: Download complete 
b5852211f44b: Download complete 
448b1d058ed3: Download complete 
7e9b3835bb04: Download complete 
553f7b1a42b4: Download complete 
72b3b98817e6: Download complete 
5650d462556e: Download complete 
147ce5c7866e: Download complete 
278bde83838c: Download complete 
docker: dial tcp: lookup registry-1.docker.io on 192.168.5.3:53: read udp 192.168.5.15:38799->192.168.5.3:53: i/o timeout.
See 'docker run --help'.
make: *** [dev-env-shell] Error 125
➜  hasura-storage git:(tags/cache-vips-build) docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

@stale
Copy link

stale bot commented May 11, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 11, 2023
@stale stale bot closed this May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants