Skip to content

How to persist the settings.json? #965

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

Closed
mlhazan opened this issue Sep 11, 2019 · 11 comments · Fixed by #969
Closed

How to persist the settings.json? #965

mlhazan opened this issue Sep 11, 2019 · 11 comments · Fixed by #969

Comments

@mlhazan
Copy link

mlhazan commented Sep 11, 2019

Every time I rerun the app, looks like it removes all the changes done in the previous session. Even it don't save the font size changes. I installed couple of packages but when I rerun the app, it looks like runs as a fresh app. Is there any way to save the settings.json?

@xlanor
Copy link

xlanor commented Sep 12, 2019

I would like to ask this as well.
I understand there is sshcode for this purpose, but I will be running code server on my ipad pro to use as a portable coding env, and Im not sure if its possible to persist this.

So far, what I have done (haven't really tried) is to mount a setting.json as a volume, then symlink it to the path that code server uses to store settings.json

I think this can be done by a docker file, but I'm using docker-compose for this so I'm still experimenting.

@sr229
Copy link
Contributor

sr229 commented Sep 12, 2019

If you're running it via Docker, you'll need to make a volume for it or bind a volume to persist your settings @xlanor @mlhazan

@xlanor
Copy link

xlanor commented Sep 12, 2019

@sr229 , thanks for the fast response.

When I try to bind it to this, such as /home/coder/.local/share/code-server/User/settings.json, it results in an error with the container not being able to create other folders in .local

jingkai@bionic-home:~/code-server$ docker-compose up
Creating network "codeserver_default" with the default driver
Creating codeserver ...
Creating codeserver ... done
Attaching to codeserver
codeserver    | (node:6) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
codeserver    | ERROR { [Error: EACCES: permission denied, mkdir '/home/coder/.local/share/code-server/extensions']
codeserver    |   [stack]:
codeserver    |    'Error: EACCES: permission denied, mkdir \'/home/coder/.local/share/code-server/extensions\'',
codeserver    |   [message]:
codeserver    |    'EACCES: permission denied, mkdir \'/home/coder/.local/share/code-server/extensions\'',
codeserver    |   errno: -13,
codeserver    |   code: 'EACCES',
codeserver    |   syscall: 'mkdir',
codeserver    |   path: '/home/coder/.local/share/code-server/extensions' }

The docker-compose file in question

   2   │ version: "3.2"
   3   │ services:
   4   │   codeserver:
   5   │     command: "--allow-http"
   6   │     container_name: codeserver
   7   │     environment:
   8   │       - PASSWORD=PWD
   9   │     image: "codercom/code-server:latest"
  10   │     ports:
  11   │       - "8443:8443"
  12   │     restart: always
  13   │     volumes:
  14   │       - "codeserver_data:/root/project"
  15   │       - "/home/jingkai/code-server/settings.json:/home/coder/.local/share/code-server/User/settings.json"
  20   │ volumes:
  21   │   codeserver_data:
  22   │     driver: local-persist
  23   │     driver_opts:
  24   │       mountpoint: /home/jingkai/data/codeserver_data

@sr229
Copy link
Contributor

sr229 commented Sep 12, 2019

That's weird. I'll go ahead and try to fix that in my end and PR it. I'll send you a patch file later for the Dockerfile while you wait so you can get up to speed.

@xlanor
Copy link

xlanor commented Sep 12, 2019

Thanks for the quick response @sr229 !
Is there a public development chat (gitter, slack, irc, discord) that you guys use? This is a really interesting project!

@xlanor
Copy link

xlanor commented Sep 12, 2019

Just an update,
Instead of mounting a single file, I just mounted the entire directory instead.
My compose file is below. This works fine now.

--- 
version: "3.2"
services: 
  codeserver:
    command: "--allow-http"
    container_name: codeserver
    env_file:
      - cs.env
    image: "codercom/code-server:latest"
    ports: 
      - "8443:8443"
    restart: always
    volumes: 
      - "codeserver_data:/root/project"
      - data:/home/coder/.local/share/code-server
volumes: 
  codeserver_data: 
    driver: local-persist
    driver_opts: 
      mountpoint: /home/jingkai/data/codeserver_data
  data:
    driver: local-persist
    driver_opts:
      mountpoint: /home/jingkai/cs_settings

@sr229
Copy link
Contributor

sr229 commented Sep 12, 2019

Thanks for the quick response @sr229 !
Is there a public development chat (gitter, slack, irc, discord) that you guys use? This is a really interesting project!

yes we do @xlanor! Join us over in Discord.

@sr229
Copy link
Contributor

sr229 commented Sep 12, 2019

Just an update,
Instead of mounting a single file, I just mounted the entire directory instead.
My compose file is below. This works fine now.

--- 
version: "3.2"
services: 
  codeserver:
    command: "--allow-http"
    container_name: codeserver
    env_file:
      - cs.env
    image: "codercom/code-server:latest"
    ports: 
      - "8443:8443"
    restart: always
    volumes: 
      - "codeserver_data:/root/project"
      - data:/home/coder/.local/share/code-server
volumes: 
  codeserver_data: 
    driver: local-persist
    driver_opts: 
      mountpoint: /home/jingkai/data/codeserver_data
  data:
    driver: local-persist
    driver_opts:
      mountpoint: /home/jingkai/cs_settings

Ah I see! I do believe mounting the entire .code-server directory is more ideal, yes.

@sr229
Copy link
Contributor

sr229 commented Sep 12, 2019

Documented the process now so other folks won't encounter the same problem. Thanks for reporting.

@xlanor
Copy link

xlanor commented Sep 13, 2019

Thanks for the update @sr229 !

@kebler-net
Copy link

maybe image has changed a bit in terms of FS organization but I just bind mounted the /config directory in the container and that gets it all including settings.json which is in /config/data/User in the container. Of note I bound again /config/workspace which makes it easy to identify files to edit in host cause they are separate from the rest of the config.

version: "3.8"
services:
  code-server:
    image: ghcr.io/linuxserver/code-server
    container_name: ${Name}
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - PASSWORD=${Password}
    volumes:
      - ${Config}:/config
      - ${Files}:/config/workspace

    ports:
      - ${Port}:8443
    restart: unless-stopped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants