solidnerd / docker-bookstack

BookStack in a container
MIT License
448 stars 194 forks source link

mv: cannot move '.env' to '.env.bak': Device or resource busy #486

Closed MatthK closed 2 months ago

MatthK commented 2 months ago

I'm trying to upgrade a Version 23.5.1 to the latest version.

I have changed the version in docker-compose.yml and then added a line for the APP_KEY.

The container comes up, but then in the log file all I can see is mv: cannot move '.env' to '.env.bak': Device or resource busy

What am I missing to be able to update to the latest version?

HJF9w commented 2 months ago

Please post the contents of your current docker-compose.yml and any .env files if you are using them. See also the note in the readme:

Versions higher than 23.6.2 no longer use an in-container .env file for environment variable management. Instead, the preferred approach is to manage them directly with the container runtime (e.g. Docker's -e). This is to simplify troubleshooting if and when errors occur. The most important change is that ${APP_KEY} is no longer provided for you, instead it is up to the operator to ensure this value is present. Versions prior to this supplied ${APP_KEY} (with a default of SomeRandomStringWith32Characters. A full reference of available environment variables is available in the Bookstack repository

MatthK commented 2 months ago

Ok, so here is the content of the current docker-compose.yml. I basically just changed the line image: solidnerd/bookstack:23.5.1 to the new version number and uncomment the APP_KEY.

version: '2'
services:
  bookstack:
    container_name: "bookstack"
    restart: unless-stopped
    image: solidnerd/bookstack:23.5.1
    environment:
    - DB_HOST=vs03.domain.com:3306
    - DB_DATABASE=bookstack
    - DB_USERNAME=bookstack
    - DB_PASSWORD=secretPassword
    #set the APP_ to the URL of bookstack without without a trailing slash APP_URL=https://example.com
    - APP_URL=https://bookstack.xtc-gelato.org
    #- APP_KEY=secretKEY
    volumes:
    - /home/matth/bookstack/uploads:/var/www/bookstack/public/uploads
    - /home/matth/bookstack/storage-uploads:/var/www/bookstack/storage/uploads
    - type: bind
      source: /home/matth/bookstack/config/.env
      target: /var/www/bookstack/.env
    ports:
    - "8282:8080"

volumes:
 uploads:
 storage-uploads:

The .env file has the following content.

      # Environment
      APP_ENV=production
      APP_DEBUG=false
      APP_KEY=SomeRandomStringWith32Characters

      # The below url has to be set if using social auth options
      # or if you are not using BookStack at the root path of your domain.
      APP_URL=https://bookstack.domain.com

      # Database details
      DB_HOST=vs03.domain.com:3306
      DB_DATABASE=bookstack
      DB_USERNAME=bookstack
      DB_PASSWORD=secretPassword

      # Cache and session
      CACHE_DRIVER=file
      SESSION_DRIVER=file
      # If using Memcached, comment the above and uncomment these
      #CACHE_DRIVER=memcached
      #SESSION_DRIVER=memcached
      QUEUE_DRIVER=sync

      # Memcached settings
      # If using a UNIX socket path for the host, set the port to 0
      # This follows the following format: HOST:PORT:WEIGHT
      # For multiple servers separate with a comma
      MEMCACHED_SERVERS=127.0.0.1:11211:100

      # Storage
      STORAGE_TYPE=local
      # Amazon S3 Config
      STORAGE_S3_KEY=false
      STORAGE_S3_SECRET=false
      STORAGE_S3_REGION=false
      STORAGE_S3_BUCKET=false
      # Storage URL
      # Used to prefix image urls for when using custom domains/cdns
      STORAGE_URL=false

      # General auth
      AUTH_METHOD=standard

      # Social Authentication information. Defaults as off.
      GITHUB_APP_ID=false
      GITHUB_APP_SECRET=false
      GOOGLE_APP_ID=false
      GOOGLE_APP_SECRET=false

      # External services such as Gravatar
      DISABLE_EXTERNAL_SERVICES=false

      # LDAP Settings
      LDAP_SERVER=false
      LDAP_BASE_DN=false
      LDAP_DN=false
      LDAP_PASS=false
      LDAP_USER_FILTER=false
      LDAP_VERSION=false

      # Mail settings
      MAIL_DRIVER=smtp
      MAIL_HOST=mail.domain.com
      MAIL_PORT=465
      MAIL_USERNAME=bookstack@domain.com
      MAIL_PASSWORD=secretPassword
      MAIL_ENCRYPTION=tls
      # URL used for social login redirects, NO TRAILING SLASH
MatthK commented 2 months ago

Ok, so I just moved all the lines from the .env to the docker-compose.yml file and restarted the container. Now this time it worked.

However, I somehow must not have paid attention when I setup the first container, as my APP_KEY is still the SomeRandomStringWith32Characters.

I tried to update that with a better one now, however I then get "An error occurred" message and I can't see my existing content. Is there a way to change that APP_KEY in an existing setup?

rjhenry commented 2 months ago

To the best of my knowledge, there's no way to change the APP_KEY. From documentation, I think that it's only used in encrypting MFA tokens; if you remove MFA tokens from users, change the key, then set up MFA again you might get away with this. Do this at your own risk, and take plenty of backups though! I'm 100% sure but can't see any obvious other uses.

You might want to check on the upstream Bookstack repository, as there might be more information there.