diff --git a/.dockerignore b/.dockerignore index 29fa987..a96bd42 100644 --- a/.dockerignore +++ b/.dockerignore @@ -16,3 +16,5 @@ # Database migrations !migrations/ + +!docker/crontab diff --git a/docker/Dockerfile.rel b/docker/Dockerfile.rel index acb3cb4..4f4c54d 100644 --- a/docker/Dockerfile.rel +++ b/docker/Dockerfile.rel @@ -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"] diff --git a/docker/crontab b/docker/crontab new file mode 100644 index 0000000..16fbbcd --- /dev/null +++ b/docker/crontab @@ -0,0 +1 @@ +# This'll be filled up later diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 14e90d2..4e1f9fb 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -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' diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh deleted file mode 100755 index 5c345c7..0000000 --- a/docker/entrypoint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh - -crond -b - -exec "/app/bin/server"