mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 00:38:43 +00:00
feat(docker): add docker and publish images to ghcr (#411)
Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
.idea/
|
||||
.git/
|
||||
.vs/
|
||||
.vscode/
|
||||
build/
|
||||
node_modules/
|
||||
+49
-53
@@ -2,56 +2,52 @@
|
||||
# Read https://github.com/jef/nvidia-snatcher#customization for help on customizing this file
|
||||
#############################################################################################
|
||||
|
||||
BROWSER_TRUSTED=""
|
||||
COUNTRY=""
|
||||
DISCORD_NOTIFY_GROUP=""
|
||||
DISCORD_WEB_HOOK=""
|
||||
EMAIL_USERNAME=""
|
||||
EMAIL_TO=""
|
||||
EMAIL_PASSWORD=""
|
||||
HEADLESS=""
|
||||
IN_STOCK_WAIT_TIME=""
|
||||
LOG_LEVEL=""
|
||||
LOW_BANDWIDTH=""
|
||||
MAX_PRICE_3070=""
|
||||
MAX_PRICE_3080=""
|
||||
MAX_PRICE_3090=""
|
||||
MICROCENTER_LOCATION=""
|
||||
NVIDIA_ADD_TO_CART_ATTEMPTS=""
|
||||
NVIDIA_SESSION_TTL=""
|
||||
OPEN_BROWSER=""
|
||||
PAGE_BACKOFF_MIN=""
|
||||
PAGE_BACKOFF_MAX=""
|
||||
PAGE_SLEEP_MIN=""
|
||||
PAGE_SLEEP_MAX=""
|
||||
PAGE_TIMEOUT=""
|
||||
PHONE_NUMBER=""
|
||||
PHONE_CARRIER=""
|
||||
PLAY_SOUND=""
|
||||
PROXY_ADDRESS=""
|
||||
PROXY_PORT=""
|
||||
PUSHBULLET=""
|
||||
PUSHOVER_TOKEN=""
|
||||
PUSHOVER_USER=""
|
||||
PUSHOVER_PRIORITY=""
|
||||
SCREENSHOT="false"
|
||||
SHOW_ONLY_BRANDS=""
|
||||
SHOW_ONLY_MODELS=""
|
||||
SHOW_ONLY_SERIES=""
|
||||
SLACK_CHANNEL=""
|
||||
SLACK_TOKEN=""
|
||||
SMTP_ADDRESS=""
|
||||
SMTP_PORT=""
|
||||
STORES=""
|
||||
TELEGRAM_ACCESS_TOKEN=""
|
||||
TELEGRAM_CHAT_ID=""
|
||||
TWILIO_ACCOUNT_SID=""
|
||||
TWILIO_AUTH_TOKEN=""
|
||||
TWILIO_FROM_NUMBER=""
|
||||
TWILIO_TO_NUMBER=""
|
||||
TWITTER_CONSUMER_KEY=""
|
||||
TWITTER_CONSUMER_SECRET=""
|
||||
TWITTER_ACCESS_TOKEN_KEY=""
|
||||
TWITTER_ACCESS_TOKEN_SECRET=""
|
||||
TWITTER_TWEET_TAGS=""
|
||||
USER_AGENT=""
|
||||
BROWSER_TRUSTED=
|
||||
COUNTRY=
|
||||
DISCORD_NOTIFY_GROUP=
|
||||
DISCORD_WEB_HOOK=
|
||||
EMAIL_USERNAME=
|
||||
EMAIL_TO=
|
||||
EMAIL_PASSWORD=
|
||||
HEADLESS=
|
||||
IN_STOCK_WAIT_TIME=
|
||||
LOG_LEVEL=
|
||||
LOW_BANDWIDTH=
|
||||
MAX_PRICE=
|
||||
MICROCENTER_LOCATION=
|
||||
NVIDIA_ADD_TO_CART_ATTEMPTS=
|
||||
NVIDIA_SESSION_TTL=
|
||||
OPEN_BROWSER=
|
||||
PAGE_BACKOFF_MIN=
|
||||
PAGE_BACKOFF_MAX=
|
||||
PAGE_SLEEP_MIN=
|
||||
PAGE_SLEEP_MAX=
|
||||
PAGE_TIMEOUT=
|
||||
PHONE_NUMBER=
|
||||
PHONE_CARRIER=
|
||||
PLAY_SOUND=
|
||||
PROXY_ADDRESS=
|
||||
PROXY_PORT=
|
||||
PUSHBULLET=
|
||||
PUSHOVER_TOKEN=
|
||||
PUSHOVER_USER=
|
||||
PUSHOVER_PRIORITY=
|
||||
SCREENSHOT=
|
||||
SHOW_ONLY_BRANDS=
|
||||
SHOW_ONLY_MODELS=
|
||||
SHOW_ONLY_SERIES=
|
||||
SLACK_CHANNEL=
|
||||
SLACK_TOKEN=
|
||||
STORES=
|
||||
TELEGRAM_ACCESS_TOKEN=
|
||||
TELEGRAM_CHAT_ID=
|
||||
TWILIO_ACCOUNT_SID=
|
||||
TWILIO_AUTH_TOKEN=
|
||||
TWILIO_FROM_NUMBER=
|
||||
TWILIO_TO_NUMBER=
|
||||
TWITTER_CONSUMER_KEY=
|
||||
TWITTER_CONSUMER_SECRET=
|
||||
TWITTER_ACCESS_TOKEN_KEY=
|
||||
TWITTER_ACCESS_TOKEN_SECRET=
|
||||
TWITTER_TWEET_TAGS=
|
||||
USER_AGENT=
|
||||
|
||||
@@ -16,3 +16,25 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
release-type: node
|
||||
package-name: nvidia-snatcher
|
||||
- name: login into github package registry
|
||||
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
|
||||
- name: build nightly docker image
|
||||
if: ${{ ! steps.release.outputs.release_created }}
|
||||
run: |
|
||||
docker build \
|
||||
-t "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}" \
|
||||
-t "ghcr.io/${GITHUB_REPOSITORY}:nightly" .
|
||||
- name: publish nightly
|
||||
if: ${{ ! steps.release.outputs.release_created }}
|
||||
run: docker push "ghcr.io/${GITHUB_REPOSITORY}"
|
||||
- name: build latest docker image
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
run: |
|
||||
docker build \
|
||||
-t "ghcr.io/${GITHUB_REPOSITORY}:${TAG_NAME}" \
|
||||
-t "ghcr.io/${GITHUB_REPOSITORY}:latest" .
|
||||
env:
|
||||
TAG_NAME: ${{ steps.release.outputs.tag_name }}
|
||||
- name: publish latest
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
run: docker push "ghcr.io/${GITHUB_REPOSITORY}"
|
||||
|
||||
@@ -9,7 +9,7 @@ jobs:
|
||||
build-lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2.1.2
|
||||
with:
|
||||
node-version: 14
|
||||
@@ -25,3 +25,15 @@ jobs:
|
||||
npm ci
|
||||
npm run build
|
||||
npm run lint
|
||||
build-docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: dorny/paths-filter@v2
|
||||
id: changes
|
||||
with:
|
||||
filters: |
|
||||
src:
|
||||
- 'Dockerfile'
|
||||
- name: Build image
|
||||
run: docker build .
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# Build the source code
|
||||
FROM node:14.11.0-alpine3.12 AS builder
|
||||
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY package.json package.json
|
||||
COPY package-lock.json package-lock.json
|
||||
COPY tsconfig.json tsconfig.json
|
||||
RUN npm ci
|
||||
|
||||
COPY src/ src/
|
||||
RUN npm run build
|
||||
RUN npm prune --production
|
||||
|
||||
FROM node:14.11.0-alpine3.12
|
||||
|
||||
RUN apk add --no-cache chromium
|
||||
|
||||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
|
||||
DOCKER=true
|
||||
|
||||
RUN addgroup -S appuser && adduser -S -g appuser appuser \
|
||||
&& mkdir -p /home/appuser/Downloads /app \
|
||||
&& chown -R appuser:appuser /home/appuser \
|
||||
&& chown -R appuser:appuser /app
|
||||
|
||||
USER appuser
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /build/node_modules/ node_modules/
|
||||
COPY --from=builder /build/build/ build/
|
||||
|
||||
CMD [ "node", "./build/index.js" ]
|
||||
@@ -42,6 +42,8 @@ You do not need any computer skills, smarts, or anything of that nature. You are
|
||||
|
||||
### Quick overview
|
||||
|
||||
#### Native installation
|
||||
|
||||
- [Node.js 14](https://nodejs.org/en/)
|
||||
- [git](https://git-scm.com/)
|
||||
- Clone this project `git clone https://github.com/jef/nvidia-snatcher.git`
|
||||
@@ -54,6 +56,17 @@ At any point you want the program to stop, use <kbd>Ctrl</kbd> + <kbd>C</kbd>.
|
||||
|
||||
> :point_right: Please visit the [wiki](https://github.com/jef/nvidia-snatcher/wiki) if you need more help with installation.
|
||||
|
||||
#### Docker image (To run inside containers)
|
||||
|
||||
Available via GitHub Container Registry.
|
||||
|
||||
| Tag | Note |
|
||||
|:---:|---|
|
||||
| `latest` | Latest stable build |
|
||||
| `nightly` | Latest HEAD build, could be unstable |
|
||||
|
||||
Use `docker run --cap-add=SYS_ADMIN -it --rm --env-file ./.env ghcr.io/jef/nvidia-snatcher:nightly` to run.
|
||||
|
||||
### Developer notes
|
||||
|
||||
The command `npm run start:dev` can be used instead of `npm run start` to automatically restart the project when filesystem changes are detected in the `src/` folder or `.env` file.
|
||||
|
||||
@@ -118,6 +118,8 @@ const browser = {
|
||||
open: envOrBoolean(process.env.OPEN_BROWSER)
|
||||
};
|
||||
|
||||
const docker = envOrBoolean(process.env.DOCKER);
|
||||
|
||||
const logLevel = envOrString(process.env.LOG_LEVEL, 'info');
|
||||
|
||||
const notifications = {
|
||||
@@ -225,6 +227,7 @@ const store = {
|
||||
|
||||
export const config = {
|
||||
browser,
|
||||
docker,
|
||||
logLevel,
|
||||
notifications,
|
||||
nvidia,
|
||||
|
||||
@@ -35,6 +35,11 @@ async function main() {
|
||||
args.push('--disable-setuid-sandbox');
|
||||
}
|
||||
|
||||
// https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#tips
|
||||
if (config.docker) {
|
||||
args.push('--disable-dev-shm-usage');
|
||||
}
|
||||
|
||||
// Add the address of the proxy server if defined
|
||||
if (config.proxy.address) {
|
||||
args.push(`--proxy-server=http://${config.proxy.address}:${config.proxy.port}`);
|
||||
|
||||
Reference in New Issue
Block a user