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

permissions of output incorrect for standard nginx #109

Open
zeigerpuppy opened this issue Apr 1, 2021 · 0 comments
Open

permissions of output incorrect for standard nginx #109

zeigerpuppy opened this issue Apr 1, 2021 · 0 comments

Comments

@zeigerpuppy
Copy link

zeigerpuppy commented Apr 1, 2021

serving the output dir with docker container nginx:latest fails due to the permissions of the output files being incorrect (results in 13: permission error)

I have kludged a solution that keeps the built files with permission 755 but I'm sure there's a better way to do this. The umask seems OK at 0022 but the built files don't have read permission for other resulting in some issues for nginx containers.

note the line chmod -R 755 $HUGO_DESTINATION below

#!/bin/sh

WATCH="${HUGO_WATCH:=false}"
SLEEP="${HUGO_REFRESH_TIME:=-1}"
HUGO_DESTINATION="${HUGO_DESTINATION:=/output}"
echo "HUGO_WATCH:" $WATCH
echo "HUGO_REFRESH_TIME:" $HUGO_REFRESH_TIME
echo "HUGO_THEME:" $HUGO_THEME
echo "HUGO_BASEURL" $HUGO_BASEURL
echo "ARGS" $@

HUGO=/usr/local/sbin/hugo
echo "Hugo path: $HUGO"

while [ true ]
do
    if [[ $HUGO_WATCH != 'false' ]]; then
            echo "Watching..."
        $HUGO server --watch=true --source="/src" --theme="$HUGO_THEME" --destination="$HUGO_DESTINATION" --baseURL="$HUGO_BASEURL" --bind="0.0.0.0" "$@" || exit 1
    else
            echo "Building one time..."
        $HUGO --source="/src" --theme="$HUGO_THEME" --destination="$HUGO_DESTINATION" --baseURL="$HUGO_BASEURL" "$@" || exit 1
            echo "changing permissions"
        chmod -R 755 $HUGO_DESTINATION
    fi

    if [[ $HUGO_REFRESH_TIME == -1 ]]; then
        exit 0
    fi
    echo "Sleeping for $HUGO_REFRESH_TIME seconds..."
    sleep $SLEEP
done

I sub this file in my docker-compose config (ugly but effective)

    volumes:
      - ${PWD}/run.sh:/run.sh
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

No branches or pull requests

1 participant