Skip to content

Commit

Permalink
Update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
cbenning committed May 23, 2020
1 parent bcaa1e8 commit 4505d91
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 2 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,37 @@ After running `generate_site.sh`

- `cd web`
- `yarn start`

## Docker

If you don't want to fuss with anything and would like to use docker instead fo generate your site...

### Usage

Required:
* `/my-input-folder` is the absolute path to top-level photo folder
* `/my-output-folder` is the absolute path to where you want the generated site written to

```
docker run \
-v /my-input-folder:/input:ro \
-v /my-output-folder:/fussel/web/build \
cbenning/fussel:latest
```

Optional:
You can provide any value found in the .env.sample file in a docker env variable using `-e MYVAR=THING`

```
docker run \
-v /my-input-folder:/input:ro \
-v /my-output-folder:/fussel/web/build \
-e HTTP_ROOT=/my/alternate/path \
-e WATERMARK_ENABLE=false \
cbenning/fussel:latest
```

Once complete you can upload the output folder to your webserver, or see what it looks like with
`python -m http.server --directory /my-output-folder`


34 changes: 34 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM alpine:3.11.6

RUN apk update && apk add \
python3 \
py3-pillow \
py3-pip \
nodejs \
yarn \
git \
sed \
bash

RUN pip3 install --upgrade pip
COPY docker/start.sh /
RUN chmod +x start.sh

RUN mkdir fussel
COPY fussel.py \
generate_site.sh \
LICENSE \
README.md \
requirements.txt \
.env.sample \
fussel/

COPY generator fussel/generator
COPY web fussel/web

RUN cd fussel && \
pip3 install -r requirements.txt
RUN cd fussel/web && \
yarn install

CMD ["./start.sh"]
47 changes: 47 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

cd fussel

export INPUT_PATH=/input
export OUTPUT_PATH=web/build

FAILED=0

echo "" > .env

while IFS= read -r line
do
CONF_VAL_REGEX='^([A-Z_]+)=(.*)$'
if [[ $line =~ $CONF_VAL_REGEX ]]; then
CONF_VAR="${BASH_REMATCH[1]}"
if [[ ! -z "${!CONF_VAR}" ]]; then
echo "${CONF_VAR}=${!CONF_VAR}" >> .env
else
echo "${CONF_VAR}=${BASH_REMATCH[2]}" >> .env
fi
fi

REQ_CONF_VAL_REGEX='^#([A-Z_]+)=.*$'
if [[ $line =~ $REQ_CONF_VAL_REGEX ]]; then
REQ_CONF_VAR="${BASH_REMATCH[1]}"
if [[ ! -z "${!REQ_CONF_VAR}" ]]; then
echo "${REQ_CONF_VAR}=${!REQ_CONF_VAR}" >> .env
else
echo "Missing required config:"
echo "${REQ_CONF_VAR}"
FAILED=1
fi
fi

done < ".env.sample"

if (( FAILED > 0 )); then
exit 1
fi

echo "Using config: "
cat .env

./generate_site.sh


5 changes: 3 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "react-photo-gallery-with-image-viewer",
"name": "fussel",
"version": "1.0.0",
"description": "example using react-images Lightbox component",
"description": "Fussel Gallery",
"keywords": [],
"homepage": "/",
"license": "MIT",
"dependencies": {
"bulma": "^0.8.2",
"react": "^16.13.1",
Expand Down

0 comments on commit 4505d91

Please sign in to comment.