Skip to content

Commit

Permalink
Merge pull request #7 from familab/mjh/feature/current-install
Browse files Browse the repository at this point in the history
Updates for deployment to current lab space
  • Loading branch information
BZWingZero authored Feb 26, 2024
2 parents 786c07e + 2733982 commit 2ce4f20
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 6 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Docker Image Publish

on:
push:
branches: [ "release/v4" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
push_server-image:
name: Push Auth Server image to GHCR
runs-on: ubuntu-latest
steps:

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for image
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:18-alpine
LABEL org.opencontainers.image.source = "https://github.com/familab/accessController"

RUN npm install --global pnpm

WORKDIR /home

COPY tsconfig.json ./
COPY api/package.json \
api/tsconfig.json \
api/tsconfig.build.json \
api/
COPY api/src api/src

RUN cd api && \
pnpm install && \
pnpm run build

ENTRYPOINT node ./api/build/server.js
3 changes: 2 additions & 1 deletion api/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ GOOGLE.SPREADSHEET_ID=
GOOGLE.SPREADSHEET_RANGE=

# Google Account configuration
GOOGLE.CREDENTIALS_FILE=
GOOGLE.CREDENTIALS.CLIENT_EMAIL=
GOOGLE.CREDENTIALS.PRIVATE_KEY=
6 changes: 5 additions & 1 deletion api/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export const env = {
},
database: Env.string("DATABASE", ".temp.sqlite"),
google: {
credentialsFile: Env.string("GOOGLE.CREDENTIALS_FILE"),
credentials: {
client_email: Env.string("GOOGLE.CREDENTIALS.CLIENT_EMAIL"),
private_key: Env.string("GOOGLE.CREDENTIALS.PRIVATE_KEY")
.replaceAll("\\n", "\n"),
},
spreadsheetId: Env.string("GOOGLE.SPREADSHEET_ID"),
spreadsheetRange: Env.string("GOOGLE.SPREADSHEET_RANGE", "Sheet1"),
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/repositories/sheets-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class SheetsRepository {

this.sheetsClient = new Sheets({
auth: new GoogleAuth({
keyFile: env.google.credentialsFile,
credentials: env.google.credentials,
scopes: ['https://www.googleapis.com/auth/spreadsheets']
})
});
Expand Down
12 changes: 10 additions & 2 deletions nfc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import board
from busio import SPI
from digitalio import DigitalInOut, Direction

from src.display import Display
from src.reader import Reader
from src.wifi import Wifi


# Setup
print("\n\n")
print("#####################")
Expand All @@ -22,6 +22,7 @@
wifi: Wifi | None = None

board_id = uname()[0]
relay: DigitalInOut
if board_id == 'ESP32S3':
spi = board.SPI()
display = Display(spi)
Expand All @@ -32,13 +33,18 @@
display.draw_text("Connecting\nto WiFi")
wifi = Wifi()

relay = DigitalInOut(board.D13)
relay.direction = Direction.OUTPUT

elif board_id == 'rp2040':
spi = SPI(board.GP18, board.GP19, board.GP16)
reader = Reader(spi, board.GP17, board.GP20)

# relay = DigitalInOut(board.D13)
# relay.direction = Direction.OUTPUT
else:
raise RuntimeError(f"Unsupported platform {board_id}")


# Loop
while True:
if display:
Expand All @@ -60,8 +66,10 @@
if can_access:
if display:
display.draw_text("Access Granted", 0x00FF00)
relay.value = 1
else:
if display:
display.draw_text("Access Denied", 0xFF0000)

time.sleep(3)
relay.value = 0
2 changes: 1 addition & 1 deletion nfc/src/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, spi: SPI):
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
# display = ST7789(display_bus, rotation=270, width 240, height=135, rowstart = 40, colstart=53)
self.display = ST7789(
display_bus, rotation=270, width=240, height=135, rowstart=40, colstart=53
display_bus, rotation=90, width=240, height=135, rowstart=40, colstart=53
)

def draw_text(self,
Expand Down

0 comments on commit 2ce4f20

Please sign in to comment.