Skip to content

Commit a1d3c26

Browse files
authored
Merge pull request #3 from eniraa/docker
add docker things
2 parents d5d10f8 + 6366237 commit a1d3c26

File tree

5 files changed

+148
-4
lines changed

5 files changed

+148
-4
lines changed

.dockerignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
6+
7+
**/.classpath
8+
**/.dockerignore
9+
**/.env
10+
**/.git
11+
**/.gitignore
12+
**/.project
13+
**/.settings
14+
**/.toolstarget
15+
**/.vs
16+
**/.vscode
17+
**/.next
18+
**/.cache
19+
**/*.*proj.user
20+
**/*.dbmdl
21+
**/*.jfm
22+
**/charts
23+
**/docker-compose*
24+
**/compose*
25+
**/Dockerfile*
26+
**/node_modules
27+
**/npm-debug.log
28+
**/obj
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
**/build
32+
**/dist
33+
LICENSE.txt
34+
README.md
35+
SECURITY.md

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
-
4+
package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
-
9+
package-ecosystem: "npm"
10+
directory: "/"
11+
schedule:
12+
interval: "daily"

.github/workflows/build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
if: github.ref == 'refs/heads/main'
13+
permissions:
14+
packages: write
15+
steps:
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v4
19+
-
20+
name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
-
23+
name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
-
26+
name: Login to GitHub Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
-
33+
name: Build and Push Docker Image
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
38+
push: true
39+
tags: ghcr.io/${{ github.repository }}:latest
40+
cache-from: type=gha
41+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Comments are provided throughout this file to help you get started.
4+
# If you need more help, visit the Dockerfile reference guide at
5+
# https://docs.docker.com/engine/reference/builder/
6+
FROM node:alpine3.19
7+
# Use production node environment by default.
8+
ENV NODE_ENV production
9+
10+
11+
WORKDIR /usr/src/app
12+
13+
# Download dependencies as a separate step to take advantage of Docker's caching.
14+
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
15+
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
16+
# into this layer.
17+
RUN --mount=type=bind,source=package.json,target=package.json \
18+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
19+
--mount=type=cache,target=/root/.npm \
20+
npm ci --omit=dev
21+
22+
# Run the application as a non-root user.
23+
USER node
24+
25+
# Copy the rest of the source files into the image.
26+
COPY . .
27+
28+
# Run the application.
29+
CMD node main.js

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,29 @@ git clone https://github.com/marigarey/canvas-notion-integration.git
2929

3030
# Open this project
3131
cd canvas-notion-integration
32+
```
3233

34+
#### Without Docker
35+
```zsh
3336
# Install dependencies
3437
npm install
3538
```
3639

40+
#### With Docker
41+
```zsh
42+
# Build image
43+
docker -t canvas-notion-integration build .
44+
```
45+
46+
> [!NOTE]
47+
> This step is not required on most architectures. GHCR should have built the latest version on the following architectures:
48+
> - `linux/amd64`
49+
> - `linux/arm/v6`
50+
> - `linux/arm/v7`
51+
> - `linux/arm64`
52+
> - `linux/ppc64le`
53+
> - `linux/s390x`
54+
3755
### 2. Canvas Token Access
3856

3957
Go to your Canvas Profile Settings and scroll down to `Approved Integrations`.
@@ -82,14 +100,23 @@ NOTION_DATABASE='default'
82100

83101
### 6. Run Code
84102

85-
```zhs
86-
node main.js
87-
```
88-
89103
> [!IMPORTANT]
90104
> To update your database you will have to run the script every time there is a change in Canvas
91105
> It is recomended to rerun the code every semester or class/assignment changes
92106
107+
#### Without Docker
108+
```zsh
109+
node main.js
110+
```
111+
112+
#### With Docker
113+
```zsh
114+
docker run --env-file ./.env canvas-notion-integration
115+
```
116+
117+
> [!NOTE]
118+
> If you did not choose to build the image yourself, you can replace `canvas-notion-integration` with `ghcr.io/marigarey/canvas-notion-integration:latest`
119+
93120
## Other Information
94121

95122
In the future I do plan to add more to this, possibly blocks outside of the database.

0 commit comments

Comments
 (0)