Skip to content

Commit

Permalink
Workaround moby/moby#2259
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunamaru committed Nov 14, 2020
1 parent 686d8ee commit 0c54f56
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Expand Up @@ -9,15 +9,17 @@ RUN ./gradle-6.7/bin/gradle assemble --no-daemon --warning-mode all

FROM amazoncorretto:11-alpine

COPY --from=builder --chown=nobody:nobody /workspace/build/libs/*.jar /workspace/spodlivoi.jar

RUN apk add --no-cache -q \
ffmpeg \
tzdata \
&& \
cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime && \
echo "Europe/Moscow" > /etc/timezone
echo "Europe/Moscow" > /etc/timezone && \
wget https://github.com/tianon/gosu/releases/download/1.12/gosu-amd64 && \
mv gosu-amd64 /bin/gosu

COPY ./utils/docker-entrypoint.sh /bin
COPY --from=builder --chown=nobody:nobody /workspace/build/libs/*.jar /workspace/spodlivoi.jar

WORKDIR /workspace
USER nobody
CMD java -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -jar spodlivoi.jar
ENTRYPOINT [ "/bin/docker-entrypoint.sh" ]
6 changes: 0 additions & 6 deletions README.md
Expand Up @@ -14,12 +14,6 @@ Create new bot with [@BotFather](https://t.me/BotFather) and fill your values in
You should replace `TELEGRAM_BOT_TOKEN` and `TELEGRAM_BOT_USERNAME` at least before starting.
Start is simple as `docker-compose up --build -d`

**Note:** Docker has very annoing [bug #2259](https://github.com/moby/moby/issues/2259) that will cause exception on first start:
```Unable to create file /var/log/spodlivoi.log java.io.IOException: Permission denied```
If you encountered this, run once on your host:
```chown -R $(docker-compose exec spodlivoi id -u) $(docker inspect spodlivoibot_spodlivoilogs -f {{.Mountpoint}})```
Although, if you don't need persistent logs, you can simply ignore this.

Demo: [@spodlivoi_bot](https://t.me/spodlivoi_bot)

<!-- badge links -->
Expand Down
14 changes: 7 additions & 7 deletions docker-compose.yml
Expand Up @@ -2,7 +2,7 @@ version: '3.7'

services:

spodlivoi:
app:
image: docker.pkg.github.com/tsunamaru/spodlivoibot/ci-build:latest
build:
dockerfile: Dockerfile
Expand All @@ -16,7 +16,7 @@ services:
LOGGING_FILE_NAME: /var/log/spodlivoi.log
restart: always
volumes:
- spodlivoilogs:/var/log
- logs:/var/log
depends_on:
- db
- redis
Expand All @@ -29,16 +29,16 @@ services:
POSTGRES_DB: spodlivoi
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- spodlivoidb:/var/lib/postgresql/data/pgdata
- db:/var/lib/postgresql/data
restart: always

redis:
image: redis:6-alpine
volumes:
- spodlivoiredis:/data
- redis:/data
restart: always

volumes:
spodlivoidb:
spodlivoilogs:
spodlivoiredis:
db:
logs:
redis:
5 changes: 5 additions & 0 deletions utils/docker-entrypoint.sh
@@ -0,0 +1,5 @@
#!/bin/sh
chmod +x /bin/gosu
chown -R nobody:nobody /var/log

exec /bin/gosu nobody java -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -jar spodlivoi.jar

0 comments on commit 0c54f56

Please sign in to comment.