Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

fix: Replace axios with fetch and add timeout #85

Merged
merged 20 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
cache-dependency-path: package-lock.json
- run: npm ci
- run: npm run lint
docker:
docker-alpine:
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -54,6 +54,37 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
docker-debian:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: docker/metadata-action@v4
id: meta
with:
images: ghcr.io/joshuaavalon/cloudflare-ddns
tags: |
type=sha
type=ref,event=branch
flavor: |
suffix=-debian,onlatest=true
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
file: Dockerfile.debian
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
release-please:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
Expand Down
39 changes: 37 additions & 2 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
schedule:
- cron: "0 0 * * *"
jobs:
docker:
docker-alpine:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -33,9 +33,44 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v3
- uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
docker-debian:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: docker/metadata-action@v4
id: meta
with:
images: ghcr.io/joshuaavalon/cloudflare-ddns
tags: |
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=ref,event=branch
flavor: |
suffix=-debian,onlatest=true
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
file: Dockerfile.debian
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN npm ci && \

RUN mkdir /packages && \
cp --parents -r packages/*/lib / && \

cp --parents packages/*/package.json /

FROM $BASE_IMAGE
Expand All @@ -24,6 +25,7 @@ ENV CF_DNS__CONFIG=/app/config.yaml
ENV NODE_ENV=production
ENV CF_DNS__CRON='*/5 * * * *'
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
ENV NPM_CONFIG_LOGLEVEL=warn

COPY --from=builder /packages /app/packages/
COPY package.json package-lock.json index.mjs /app/
Expand Down
53 changes: 53 additions & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ARG BASE_IMAGE=node:18-slim

FROM $BASE_IMAGE as builder

WORKDIR /app

COPY packages /app/packages/
COPY package.json tsconfig.json package-lock.json /app/

RUN npm ci && \
npm run build && \
rm -rf packages/*/lib/__tests__

RUN mkdir /packages && \
cp --parents -r packages/*/lib / && \
cp --parents packages/*/package.json /

FROM $BASE_IMAGE

WORKDIR /app

ENV NPM_CONFIG_PREFIX=/app/.npm
ENV CF_DNS__CONFIG=/app/config.yaml
ENV NODE_ENV=production
ENV CF_DNS__CRON='*/5 * * * *'
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
ENV NPM_CONFIG_LOGLEVEL=warn

COPY --from=builder /packages /app/packages/
COPY package.json package-lock.json index.mjs /app/
COPY docker/root/ /

RUN chmod +x /app/cloudflare.sh /app/start.sh

RUN apt-get update && apt-get install -y cron

SHELL ["/bin/bash", "-c"]

RUN npm ci

ENV ZONE=
ENV HOST=
ENV EMAIL=
ENV API=
ENV TTL=
ENV PROXY=
ENV DEBUG=
ENV FORCE_CREATE=
ENV RUNONCE=
ENV IPV6=

ENTRYPOINT ["/app/start.sh"]
CMD []
6 changes: 3 additions & 3 deletions docker/root/app/cloudflare.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

cd /app
cd /app;

if [ "$CF_DNS__LOG_TYPE" == "json" ]; then
npm run --cache /home/node/.npm start:json;
su node -c "npm run --cache /home/node/.npm start:json";
else
npm run --cache /home/node/.npm start:pretty;
su node -c "npm run --cache /home/node/.npm start:pretty";
fi
20 changes: 13 additions & 7 deletions docker/root/app/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else
";
fi

chown node:node /app
chown node:node /app;

if [ "$CF_DNS__LOG_TYPE" == "json" ]; then
msg='{"level":30,"time":';
Expand All @@ -35,9 +35,15 @@ else
echo "Setting crontab to ${CF_DNS__CRON}";
fi

# Delete last line
sed -i '$ d' /etc/crontabs/root
echo -e "${CF_DNS__CRON} /app/cloudflare.sh" >> /etc/crontabs/root
chmod 600 /etc/crontabs/root

crond -f
if [ -f /etc/debian_version ]; then
printenv > /etc/environment;
echo -e "${CF_DNS__CRON} root /app/cloudflare.sh > /proc/1/fd/1 2>&1" > /etc/cron.d/cloudflare-ddns;
chmod 600 /etc/cron.d/cloudflare-ddns;
cron -f;
else
# Delete last line
sed -i '$ d' /etc/crontabs/root;
echo -e "${CF_DNS__CRON} /app/cloudflare.sh" >> /etc/crontabs/root;
chmod 600 /etc/crontabs/root;
crond -f;
fi
8 changes: 0 additions & 8 deletions docker/root/etc/crontabs/root

This file was deleted.

Loading