replaced CMD in the docker file with ENTRYPOINT and docker-entrypoint.sh
This commit is contained in:
25
Dockerfile
25
Dockerfile
@@ -10,7 +10,7 @@ RUN set -eux && \
|
|||||||
apt-get upgrade -y -qq && \
|
apt-get upgrade -y -qq && \
|
||||||
echo "Installing tools" && \
|
echo "Installing tools" && \
|
||||||
apt-get install -y -qq \
|
apt-get install -y -qq \
|
||||||
curl unzip cron ca-certificates logrotate && \
|
curl unzip cron ca-certificates logrotate dos2unix && \
|
||||||
echo "Cleaning up" && \
|
echo "Cleaning up" && \
|
||||||
apt-get --yes autoremove --purge && \
|
apt-get --yes autoremove --purge && \
|
||||||
apt-get clean --yes && \
|
apt-get clean --yes && \
|
||||||
@@ -19,9 +19,14 @@ RUN set -eux && \
|
|||||||
rm --recursive --force --verbose /var/tmp/* && \
|
rm --recursive --force --verbose /var/tmp/* && \
|
||||||
rm --recursive --force --verbose /var/cache/apt/archives/* && \
|
rm --recursive --force --verbose /var/cache/apt/archives/* && \
|
||||||
truncate --size 0 /var/log/*log
|
truncate --size 0 /var/log/*log
|
||||||
|
COPY ./docker/cron-bun-log /etc/logrotate.d/
|
||||||
|
COPY ./docker/Crontab /etc/cron.d/
|
||||||
|
RUN chmod 0644 /etc/cron.d/Crontab
|
||||||
|
|
||||||
# install BunJs
|
# install BunJs
|
||||||
RUN curl -fsSL https://bun.com/install | bash
|
RUN curl -fsSL https://bun.com/install | bash
|
||||||
ENV PATH="/root/.bun/bin:$PATH"
|
ENV PATH="/root/.bun/bin:$PATH"
|
||||||
|
RUN ln -s /root/.bun/bin/bun /usr/local/bin/bun
|
||||||
# install dependencies into temp directory
|
# install dependencies into temp directory
|
||||||
# this will cache them and speed up future builds
|
# this will cache them and speed up future builds
|
||||||
FROM base AS install
|
FROM base AS install
|
||||||
@@ -34,26 +39,20 @@ RUN mkdir -p /temp/prod
|
|||||||
COPY package.json bun.lock /temp/prod/
|
COPY package.json bun.lock /temp/prod/
|
||||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||||
|
|
||||||
COPY ./docker/Crontab /etc/cron.d/
|
|
||||||
RUN chmod 0644 /etc/cron.d/Crontab
|
|
||||||
COPY ./docker/cron-bun-log /etc/logrotate.d/
|
|
||||||
RUN mkdir /var/log/cron && touch /var/log/cron.log
|
|
||||||
|
|
||||||
# copy node_modules from temp directory
|
# copy node_modules from temp directory
|
||||||
# then copy all (non-ignored) project files into the image
|
# then copy all (non-ignored) project files into the image
|
||||||
FROM base AS prerelease
|
FROM base AS prerelease
|
||||||
COPY --from=install /temp/dev/node_modules node_modules
|
COPY --from=install /temp/dev/node_modules node_modules
|
||||||
COPY . ./
|
COPY . ./
|
||||||
# [optional] tests & build
|
# [optional] tests & build
|
||||||
ENV NODE_ENV=production
|
|
||||||
|
|
||||||
# copy production dependencies and source code into final image
|
# copy production dependencies and source code into final image
|
||||||
FROM base AS release
|
FROM base AS release
|
||||||
|
ENV NODE_ENV=production
|
||||||
COPY --from=install /temp/prod/node_modules node_modules
|
COPY --from=install /temp/prod/node_modules node_modules
|
||||||
COPY --from=prerelease /opt/app/package.json .
|
|
||||||
#COPY --from=prerelease .entrypoint.sh .
|
|
||||||
COPY . ./
|
COPY . ./
|
||||||
RUN mkdir /var/log/cron && touch /var/log/cron.log
|
COPY ./docker/docker-entrypoint.sh /opt/app/docker-entrypoint.sh
|
||||||
VOLUME /opt/app/data/db
|
#COPY --from=prerelease .entrypoint.sh .
|
||||||
# VOLUME /var/log/cron
|
RUN dos2unix /opt/app/docker-entrypoint.sh && \
|
||||||
CMD bun run ./src/app.ts --today && cron && tail -f /var/log/cron.log
|
chmod +x /opt/app/docker-entrypoint.sh
|
||||||
|
ENTRYPOINT [ "/opt/app/docker-entrypoint.sh" ]
|
||||||
15
docker/docker-entrypoint.sh
Normal file
15
docker/docker-entrypoint.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
bun run ./src/app.ts --today
|
||||||
|
|
||||||
|
echo "ntfy_on=$ntfy_on" >> /etc/environment
|
||||||
|
echo "ntfy_username=$ntfy_username" >> /etc/environment
|
||||||
|
echo "ntfy_password=$ntfy_password" >> /etc/environment
|
||||||
|
echo "ntfy_host=$ntfy_host" >> /etc/environment
|
||||||
|
echo "ntfy_topic=$ntfy_topic" >> /etc/environment
|
||||||
|
echo "dc_on=$dc_on" >> /etc/environment
|
||||||
|
echo "dc_webhook=$dc_webhook" >> /etc/environment
|
||||||
|
echo "dc_botname=$dc_botname" >> /etc/environment
|
||||||
|
echo "dc_avatar_url=$dc_avatar_url" >> /etc/environment
|
||||||
|
|
||||||
|
# Start cron in foreground
|
||||||
|
exec cron -f
|
||||||
Reference in New Issue
Block a user