Added cronjob container (closes #29)

master^2
Jef Roosens 2021-04-17 20:52:29 +02:00
parent e62cd0bb93
commit fee37420cd
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
5 changed files with 16 additions and 7 deletions

View File

@ -16,3 +16,5 @@
# Database migrations
!migrations/
!docker/crontab

View File

@ -20,9 +20,11 @@ RUN cargo install \
# Now, we create the actual image
FROM alpine:latest
COPY ./docker/crontab /var/spool/cron/crontabs/fej
# Install some dynamic libraries needed for everything to work
# Create -non-root user
# Change permissions for crontab file
RUN apk update && \
apk add --no-cache \
curl \
@ -42,7 +44,6 @@ COPY --from=builder --chown=fej:fej /app/output/bin /app/bin
# The workdir is changed so that the config file is read properly
WORKDIR /app
COPY --chown=fej:fej Rocket.toml /app/Rocket.toml
COPY ./docker/entrypoint.sh /entrypoint.sh
HEALTHCHECK \
--interval=10s \
@ -51,4 +52,4 @@ HEALTHCHECK \
--retries=3 \
CMD curl -q localhost:8000
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/app/bin/server"]

1
docker/crontab 100644
View File

@ -0,0 +1 @@
# This'll be filled up later

View File

@ -12,6 +12,16 @@ services:
environment:
- 'DATABASE_URL=postgres://fej:fej@db:5432/fej'
cron:
image: 'chewingbever/fej:latest'
restart: 'always'
environment:
- 'DATABASE_URL=postgres://fej:fej@db:5432/fej'
entrypoint: 'crond -f'
user: 'root'
db:
image: 'postgres:13-alpine'
restart: 'always'

View File

@ -1,5 +0,0 @@
#!/usr/bin/env sh
crond -b
exec "/app/bin/server"