mirror of
https://github.com/pacnpal/markov-discord.git
synced 2025-12-20 03:01:04 -05:00
Update Docker config build
This commit is contained in:
@@ -1,7 +1,3 @@
|
|||||||
# Ignore everything
|
config
|
||||||
**/*
|
dist
|
||||||
|
node_modules
|
||||||
# Allow files and directories
|
|
||||||
!*.js
|
|
||||||
!*.json
|
|
||||||
!*.ts
|
|
||||||
41
.github/workflows/build-and-push-image.yml
vendored
41
.github/workflows/build-and-push-image.yml
vendored
@@ -1,26 +1,32 @@
|
|||||||
name: Build and push image
|
name: MultiArchDockerBuild
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- develop
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_and_push_image:
|
build_multi_arch_image:
|
||||||
name: Build Docker image and push to registries
|
name: Build multi-arch Docker image.
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
|
with:
|
||||||
|
install: true
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: charlocharlie
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
@@ -30,15 +36,32 @@ jobs:
|
|||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push master
|
||||||
id: docker_build_push
|
if: ${{ github.ref == 'refs/heads/master' }}
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
|
target: deploy
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
charlocharlie/markov-discord:latest
|
charlocharlie/markov-discord:latest
|
||||||
ghcr.io/${{ github.repository }}:latest
|
ghcr.io/${{ github.repository }}:latest
|
||||||
ghcr.io/${{ github.repository }}:${{ github.sha }}
|
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
|
||||||
|
build-args: |
|
||||||
|
COMMIT_SHA=${{ github.sha }}
|
||||||
|
cache-from: type=gha,scope=${{ github.workflow }}
|
||||||
|
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
|
||||||
|
|
||||||
- name: Image digest
|
- name: Build and push dev
|
||||||
run: echo ${{ steps.docker_build_push.outputs.digest }}
|
if: ${{ github.ref == 'refs/heads/develop' }}
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
target: deploy
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
charlocharlie/epicgames-freegames:dev
|
||||||
|
ghcr.io/claabs/epicgames-freegames-node:dev
|
||||||
|
platforms: linux/amd64
|
||||||
|
build-args: |
|
||||||
|
COMMIT_SHA=${{ github.sha }}
|
||||||
|
cache-from: type=gha,scope=${{ github.workflow }}
|
||||||
|
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
|
||||||
|
|||||||
44
Dockerfile
44
Dockerfile
@@ -2,45 +2,49 @@
|
|||||||
# BASE
|
# BASE
|
||||||
########
|
########
|
||||||
FROM node:16-alpine3.14 as base
|
FROM node:16-alpine3.14 as base
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
WORKDIR /usr/src/app
|
||||||
# Install build tools for erlpack, then install prod deps only, then remove build tools
|
|
||||||
RUN apk add --no-cache make gcc g++ python && \
|
|
||||||
npm ci --only=production && \
|
|
||||||
apk del make gcc g++ python
|
|
||||||
|
|
||||||
########
|
########
|
||||||
# BUILD
|
# BUILD
|
||||||
########
|
########
|
||||||
FROM base as build
|
FROM base as build
|
||||||
|
|
||||||
# Copy all *.json, *.js, *.ts
|
COPY package*.json ./
|
||||||
COPY . .
|
# Install build tools for erlpack, then install prod deps only
|
||||||
# Prod deps already installed, add dev deps
|
RUN apk add --no-cache make gcc g++ python3 \
|
||||||
RUN npm i
|
&& npm ci --only=production
|
||||||
|
|
||||||
|
# Copy all jsons
|
||||||
|
COPY package*.json tsconfig.json ./
|
||||||
|
|
||||||
|
# Add dev deps
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
|
COPY src src
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
########
|
########
|
||||||
# DEPLOY
|
# DEPLOY
|
||||||
########
|
########
|
||||||
FROM node:16-alpine3.14 as deploy
|
FROM base as deploy
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
ENV NPM_CONFIG_LOGLEVEL warn
|
|
||||||
|
|
||||||
# Steal node_modules from base image
|
# Steal node_modules from base image
|
||||||
COPY --from=base /usr/src/app/node_modules ./node_modules/
|
COPY --from=build /usr/src/app/node_modules node_modules
|
||||||
|
|
||||||
# Steal compiled code from build image
|
# Steal compiled code from build image
|
||||||
COPY --from=build /usr/src/app/dist ./
|
COPY --from=build /usr/src/app/dist dist
|
||||||
|
|
||||||
# Copy package.json for version number
|
# Copy package.json for version number
|
||||||
COPY package*.json ./
|
COPY package*.json ormconfig.js ./
|
||||||
|
|
||||||
RUN mkdir config
|
# RUN mkdir config
|
||||||
|
|
||||||
# RUN ls -al
|
ARG COMMIT_SHA=""
|
||||||
|
|
||||||
CMD [ "pm2-runtime", "start", "ecosystem.config.js" ]
|
ENV NODE_ENV=production \
|
||||||
|
COMMIT_SHA=${COMMIT_SHA}
|
||||||
|
|
||||||
|
CMD [ "node", "/usr/src/app/dist/index.js" ]
|
||||||
@@ -2,13 +2,14 @@
|
|||||||
"name": "markov-discord",
|
"name": "markov-discord",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"description": "A conversational Markov chain bot for Discord",
|
"description": "A conversational Markov chain bot for Discord",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
"start:ts": "ts-node src/index.ts",
|
"start:ts": "ts-node src/index.ts",
|
||||||
"build": "rimraf dist && tsc",
|
"build": "rimraf dist && tsc",
|
||||||
"lint": "tsc --noEmit && eslint **/*.ts *.js",
|
"lint": "tsc --noEmit && eslint **/*.ts *.js",
|
||||||
"docker-up": "docker run --rm -e TOKEN=abc123 -it $(docker build -q .)"
|
"docker:build": "docker build . -t charlocharlie/markov-discord:latest --target deploy",
|
||||||
|
"docker:run": "docker run --rm -ti -v $(pwd)/config:/usr/src/app/config charlocharlie/markov-discord:latest"
|
||||||
},
|
},
|
||||||
"repository": "https://github.com/claabs/markov-discord.git",
|
"repository": "https://github.com/claabs/markov-discord.git",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
Reference in New Issue
Block a user