mirror of
https://github.com/cupcakearmy/docker-ddns-cloudflare.git
synced 2024-12-21 23:36:24 +00:00
1.2.0
This commit is contained in:
parent
8904ffcbdd
commit
157ce6b7b6
10
CHANGELOG.md
10
CHANGELOG.md
@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.2.0] - 2022-02-07
|
||||
|
||||
### Added
|
||||
|
||||
- Sigterm and Sigkill hooks for graceful shutdown
|
||||
|
||||
### Changed
|
||||
|
||||
- Multistage steps to reduce image size
|
||||
|
||||
## [1.1.1] - 2022-02-07
|
||||
|
||||
### Security
|
||||
|
19
Dockerfile
19
Dockerfile
@ -1,10 +1,21 @@
|
||||
FROM node:16-alpine as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ADD ./package.json ./pnpm-lock.yaml ./
|
||||
RUN npm exec pnpm install --frozen-lockfile
|
||||
|
||||
ADD . .
|
||||
RUN npm exec pnpm run build
|
||||
|
||||
FROM node:16-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ADD . .
|
||||
RUN npm install -g pnpm
|
||||
RUN pnpm install --frozen-lockfile
|
||||
RUN pnpm run build
|
||||
ADD ./package.json ./pnpm-lock.yaml ./
|
||||
RUN npm exec pnpm install --frozen-lockfile --prod
|
||||
COPY --from=builder /app/dist/ /app/dist/
|
||||
|
||||
STOPSIGNAL SIGTERM
|
||||
|
||||
CMD ["node", "."]
|
||||
|
11
src/index.ts
11
src/index.ts
@ -3,6 +3,7 @@ import Axios from 'axios'
|
||||
import { CronJob } from 'cron'
|
||||
import { config } from 'dotenv'
|
||||
import winston from 'winston'
|
||||
import process from 'process'
|
||||
|
||||
const logger = winston.createLogger({
|
||||
level: 'info',
|
||||
@ -107,8 +108,16 @@ async function main() {
|
||||
if (changed) await update(cf, { ip, record: DNS_RECORD!, zone: ZONE! }).catch((e) => logger.error(e.message))
|
||||
}
|
||||
|
||||
new CronJob(CRON || '*/5 * * * *', fn, null, true, undefined, null, true)
|
||||
const cron = new CronJob(CRON || '*/5 * * * *', fn, null, true, undefined, null, true)
|
||||
logger.info('Started service.')
|
||||
|
||||
function terminate() {
|
||||
logger.info('Stopping service.')
|
||||
cron.stop()
|
||||
process.exit(0)
|
||||
}
|
||||
process.on('SIGINT', terminate)
|
||||
process.on('SIGTERM', terminate)
|
||||
}
|
||||
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user