-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated multiple npm packages. Refactored Dockerfile (faster build, less disk size). Added workflow for build and push bot image to Docker Hub. Reduced bot image size from 1.8gb to ~300mb. Added "watchtower" container in docker-compose.yml.
- Loading branch information
1 parent
5fe56b2
commit 7ebb9d4
Showing
12 changed files
with
584 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
node_modules | ||
package-lock.json | ||
.git | ||
*Dockerfile* | ||
*docker-compose* | ||
.env* | ||
runInDocker.* | ||
yt-cookies.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Publish Docker image | ||
|
||
on: | ||
push: | ||
branches: ['master'] | ||
pull_request: | ||
branches: ['master'] | ||
|
||
env: | ||
IMAGE_TAG: alexincube/aicotest | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Extract project version from package.json | ||
id: package-version | ||
uses: martinbeentjes/npm-get-version-action@v1.3.1 | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | ||
with: | ||
images: ${{ env.IMAGE_TAG }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ env.IMAGE_TAG }}:${{ steps.package-version.outputs.current-version }} , ${{ env.IMAGE_TAG }}:latest | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
build | ||
data | ||
/downloads/ | ||
/yt-cookies.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM bitnami/node:18.16.0 | ||
RUN apt update | ||
RUN apt install git | ||
RUN apt install -y ffmpeg | ||
FROM node:20-alpine as base | ||
RUN apk update && apk upgrade && apk add ffmpeg | ||
|
||
FROM base as build | ||
RUN apk add python3 && apk add build-base && apk add make | ||
RUN npm i -g pnpm@latest | ||
RUN mkdir -p /bot | ||
WORKDIR /bot | ||
RUN git clone https://github.com/AlexInCube/AlCoTest . | ||
RUN pnpm install | ||
WORKDIR /botbuild | ||
COPY . . | ||
RUN pnpm install --frozen-lockfile | ||
RUN pnpm run build | ||
COPY .env.production /bot | ||
COPY yt-cookies.json /bot | ||
CMD ["pnpm", "run", "production"] | ||
RUN pnpm prune --prod | ||
|
||
FROM base as prod | ||
WORKDIR /bot | ||
COPY --from=build /botbuild/build ./build | ||
COPY --from=build /botbuild/node_modules ./node_modules | ||
COPY --from=build /botbuild/package.json . | ||
CMD ["npm", "run", "production"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.