2017-09-26 21:09:31 +00:00
|
|
|
FROM microsoft/dotnet:2.0.0-sdk AS build
|
2017-07-06 09:03:51 +00:00
|
|
|
|
2017-07-07 16:00:38 +00:00
|
|
|
ARG BUILDCONFIG=RELEASE
|
|
|
|
|
|
|
|
# Copy project files to avoid restoring packages if they haven't changed
|
|
|
|
COPY *.csproj ./build/
|
|
|
|
WORKDIR /build/
|
2017-07-07 16:51:14 +00:00
|
|
|
RUN dotnet restore
|
|
|
|
|
|
|
|
COPY . .
|
2017-07-07 16:00:38 +00:00
|
|
|
RUN dotnet publish -c $BUILDCONFIG -o out
|
|
|
|
|
|
|
|
# build runtime image
|
2017-09-26 21:09:31 +00:00
|
|
|
FROM microsoft/dotnet:2.0.0-runtime
|
2017-07-07 16:00:38 +00:00
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=build /build/out ./
|
|
|
|
|
2017-07-06 09:03:51 +00:00
|
|
|
# Install Cron
|
|
|
|
RUN apt-get update -qq && apt-get -y install cron -qq --force-yes
|
|
|
|
|
2017-09-26 21:09:31 +00:00
|
|
|
# Add export environment variable script and schedule
|
|
|
|
COPY *.sh ./
|
|
|
|
COPY schedule /etc/cron.d/schedule
|
|
|
|
RUN sed -i 's/\r//' export_env.sh \
|
|
|
|
&& sed -i 's/\r//' run_app.sh \
|
|
|
|
&& sed -i 's/\r//' /etc/cron.d/schedule \
|
|
|
|
&& chmod +x export_env.sh run_app.sh \
|
|
|
|
&& chmod 0644 /etc/cron.d/schedule
|
2017-07-06 09:03:51 +00:00
|
|
|
|
|
|
|
# Create log file
|
|
|
|
RUN touch /var/log/cron.log
|
|
|
|
RUN chmod 0666 /var/log/cron.log
|
|
|
|
|
|
|
|
# Volume required for tail command
|
|
|
|
VOLUME /var/log
|
|
|
|
|
|
|
|
# Run Cron
|
2017-07-07 16:00:38 +00:00
|
|
|
CMD /app/export_env.sh && /usr/sbin/cron && tail -f /var/log/cron.log
|