Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docker file #76

Merged
merged 6 commits into from
Feb 4, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v4

- name: Cache Node.js dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -30,7 +30,7 @@ jobs:
node-version: 18

- name: Install Dependencies
run: npm ci
run: npm install

- name: Generate OAS 3.0
run: npm run generateoas
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
deployment_id: ${{ steps.deployment.outputs.deployment_id }}

- name: Cache FlyCtl binary
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.fly
key: ${{ runner.os }}-flyctl
Expand Down
19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
# Use the official Node.js image as base
FROM node:18-alpine
FROM node:18-alpine AS base

# Set metadata labels
LABEL maintainer="Srikanth <[email protected]>" \
version="1.5.0" \
description="Docker image for running Google Play API"

# Create and set the working directory
WORKDIR /home/node/app
WORKDIR /app

FROM base as build

# Copy only the package.json and package-lock.json first to leverage Docker caching
COPY package*.json ./
COPY --link package-lock.json package.json ./

RUN npm install -g [email protected]

# Install dependencies
RUN npm ci --quiet --omit=dev && npm cache clean --force
RUN npm install

# Copy the rest of the application code
COPY . .
COPY --link . .

RUN npm run generateoas

RUN npm prune

FROM base
# Copy the rest of the application code
COPY --from=build /app /app

# Expose port 3000
EXPOSE 3000

Expand Down
2,186 changes: 0 additions & 2,186 deletions PostmanCollections/GooglePlayAPI.postman_collection.json.json

This file was deleted.

4 changes: 2 additions & 2 deletions fly.production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ primary_region = "sin"

[http_service.concurrency]
type = "requests"
soft_limit = 400
hard_limit = 500
soft_limit = 800
hard_limit = 1000

[env]
COUNTRY_OF_QUERY = "IN"
Expand Down
4 changes: 2 additions & 2 deletions fly.staging.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ primary_region = "sin"

[http_service.concurrency]
type = "requests"
soft_limit = 400
hard_limit = 500
soft_limit = 800
hard_limit = 1000

[env]
COUNTRY_OF_QUERY = "IN"
Expand Down
9 changes: 6 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ router.use((req, res, next) => {
}

if (process.env.LOGGING || false) {
console.log("GPlayAPI", req.url, req.baseUrl, req.params)
console.log("GPlayAPI", req.url, req.baseUrl, req.params, "Status: ", res.statusCode)
}

next();
Expand Down Expand Up @@ -265,8 +265,11 @@ function anonymizeReplyText(replyText, userName) {
}

function errorHandler(err, req, res, next) {
res.status(400).json({ message: err.message });
next();
if (!res.headersSent) {
const status = err.message === "App not found (404)" ? 404 : 400;
res.status(status).json({ error: status === 404 ? "App not found" : "Bad Request", message: err.message, url: req.url });
}
next(err);
}

router.use(errorHandler);
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"eslint-plugin-standard": "^5.0.0",
"newman": "^6.1.0",
"newman-reporter-htmlextra": "^1.23.0",
"npm-check-updates": "^16.14.12"
"npm-check-updates": "^16.14.14"
}
}
Loading