Skip to content

Commit

Permalink
v1.7.2: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
CorySanin committed Sep 6, 2023
1 parent a8c17d0 commit 3e303fe
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 40 deletions.
52 changes: 29 additions & 23 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,47 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Build the Docker image
run: docker build . --file Dockerfile --tag "$DOCKER_USERNAME/$REPOSITORY:latest"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: ${{ env.DH_REGISTRY }}
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push to Docker Hub
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: docker push "$DOCKER_USERNAME/$REPOSITORY:latest"

- name: Log in to the Container registry
uses: docker/login-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.GH_REGISTRY }}
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
- id: string
name: Prepare GitHub Docker image name
uses: ASzc/change-string-case-action@v5
with:
images: ${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Push to GitHub
uses: docker/build-push-action@v2
string: ${{ env.IMAGE_NAME }}

- name: Build and push
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v4
with:
context: .
target: deploy
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.DOCKER_USERNAME }}/${{ env.REPOSITORY }}:latest
${{ env.GH_REGISTRY }}/${{ steps.string.outputs.lowercase }}:latest
platforms: linux/amd64,linux/arm64,linux/arm/v7
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,mode=max,scope=${{ github.workflow }}

16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@ WORKDIR /usr/src/app
COPY package*.json ./

ENV NPM_CONFIG_LOGLEVEL warn
RUN npm ci --only=production
RUN npm ci --only=production || (\
apk add --no-cache make g++ && \
apk add --no-cache vips-cpp vips-dev --repository https://dl-cdn.alpinelinux.org/alpine/edge/community/ && \
npm install -g node-gyp && \
npm ci --only=production --build-from-source )

COPY . .

FROM node:lts-alpine3.18
FROM node:lts-alpine3.18 AS deploy

HEALTHCHECK --timeout=3s \
CMD curl --fail http://localhost:8081/healthcheck || exit 1

WORKDIR /usr/src/app

RUN apk add --no-cache curl && \
apk add --no-cache vips --repository https://dl-cdn.alpinelinux.org/alpine/edge/community/

COPY --from=install /usr/src/app /usr/src/app/

USER node

CMD [ "npm", "start" ]
CMD [ "node", "index" ]

EXPOSE 8080
27 changes: 24 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ let config = {
donate: process.env.DONATE || null
}

let servers = [];

/**
* Close all servers
*/
function shutdown() {
console.log('\nShutting down...');
servers.forEach(serv => {
serv.close();
});
}

/**
* Check if domain is on the blacklist
* @param {string} domain
Expand Down Expand Up @@ -343,6 +355,10 @@ http.get('/out.xml', function (req, res) {
res.redirect('/feed/out.xml?in=' + req.query.in);
});

privateapp.get('/healthcheck', (req, res) => {
res.send('Healthy');
});

privateapp.get('/metrics', async (req, res) => {
try {
res.set('Content-Type', register.contentType);
Expand Down Expand Up @@ -372,6 +388,11 @@ fs.readFile(cfgfile, 'utf8', function (err, data) {
else {
console.log('No config file found. Loading default configuration.');
}
http.listen(config.port, () => console.log(`zune-podcasts listening on port ${config.port}!`));
privateapp.listen(config.privateport, () => { });
});
servers.push(
http.listen(config.port, () => console.log(`zune-podcasts listening on port ${config.port}!`)),
privateapp.listen(config.privateport, () => { })
);
});

process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zune-podcasts",
"version": "1.7.1",
"version": "1.7.2",
"description": "corrects problematic podcast feeds for the Zune desktop software",
"main": "index.js",
"scripts": {
Expand All @@ -20,6 +20,6 @@
"express-useragent": "1.0.15",
"phin": "3.7.0",
"prom-client": "14.2.0",
"sharp": "0.32.4"
"sharp": "0.32.5"
}
}

0 comments on commit 3e303fe

Please sign in to comment.