'Google Cloud Build: error while creating mount source path - mkdir /workspace: read-only file system
One of my Google Cloud Build steps is (simplified):
- name: "gcr.io/cloud-builders/docker"
id: step-1
entrypoint: bash
args: ["./toolbelt.sh"]
And inside the toolbelt.sh is the following (simplified):
...
...
docker build \
--platform linux/amd64 \
--build-arg USER=$USER \
--file build.Dockerfile \
--quiet \
--tag my_image ../
docker run \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume /workspace/foo/:/app/foo \
--tty \
my_image
But I am getting the following error from the cloud-build-local tool:
docker: Error response from daemon: error while creating mount source path '/workspace/foo': mkdir /workspace: read-only file system.
The /workspace directory contains all of my repository files. Is it possible to volume map the foo sub-directory into the container like this?
Thanks!
Solution 1:[1]
I found the solution with help from this GitHub Gist
When using cloud-build-local, you must invoke like this:
cloud-build-local \
-dryrun=false \
-config=cloudbuild.yaml \
-substitutions _MOUNT_NAME=`pwd` \
-bind-mount-source \
.
And then send _MOUNT_NAME into the shell script instead of /workspace:
- name: "gcr.io/cloud-builders/docker"
id: step-1
entrypoint: bash
env:
- '_MOUNT_NAME=${_MOUNT_NAME}'
args: ["./toolbelt.sh"]
And in the shell script:
...
...
docker build \
--platform linux/amd64 \
--build-arg USER=$USER \
--file build.Dockerfile \
--quiet \
--tag my_image ../
docker run \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume ${_MOUNT_NAME}/foo/:/app/foo \
--tty \
my_image
Solution 2:[2]
Is your app used by many users at the same time? How will you handle new lessons added by other users? I think you misunderstood the main concept of vuex, which is to have a centralized store to keep the state through the whole app. IMO, there are 2 ways to face this:
Fetch your data from DB all the time with no need for vuex. I don't see any complexity to avoid fetching data from DB as many times as you need. In this way, if any other user adds/deletes/updates a lesson/activity/unit you will be sure that you are seeing everything up-to-date.
Using vuex + Websockets. Implementing vuex + WebSockets gives a really nice user experience. You can fetch all data when the app mounts, and then listen for WebSocket events so you can hydrate your vuex state. This way is a little more complex since you have to maintain a WebSocket server.
In addition, keeping your data within your localStorage seems insecure to me. You could manipulate what is stored and send whatever you want to your API.
Saying that I would ask myself:
- Do I need to keep my data through the whole app?
- Can any other user add/update/delete anything that I need to know?
- Are queries really complex to impact my app performance?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jordan Arseno |
| Solution 2 | Luciano |
