Skip to content

Commit

Permalink
K3s deployment (#126)
Browse files Browse the repository at this point in the history
* fix(deployment):  fix docker config
- make CLIENT_ID and CLIENT_SECRET configurable
  • Loading branch information
cgawron authored Oct 9, 2023
1 parent 50577f4 commit f96caba
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
docker.env
config/config.env
src/config/config.env
node_modules/**
build/**

Expand Down
16 changes: 9 additions & 7 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM node:18-bullseye as build
ARG REACT_APP_GOOGLE_ID=692793330469-6iupo55tt0kelejcie26m4njeckbmnv8.apps.googleusercontent.com
ARG REACT_APP_URL=/meeting
ARG REACT_APP_API_URL=https://www.ki.fh-swf.de/meeting/api/v1
ARG CLIENT_ID=692793330469-6iupo55tt0kelejcie26m4njeckbmnv8.apps.googleusercontent.com
ARG CLIENT_SECRET
ARG APP_URL=/meeting
ARG APP_API_URL=https://hopper.fh-swf.de/meeting/api/v1

ENV REACT_APP_GOOGLE_ID=${REACT_APP_GOOGLE_ID}
ENV REACT_APP_URL=${REACT_APP_URL}
ENV REACT_APP_API_URL=${REACT_APP_API_URL}
ENV CLIENT_ID=${CLIENT_ID}
ENV CLIENT_SECRET=${CLIENT_SECRET}
ENV APP_URL=${APP_URL}
ENV APP_API_URL=${APP_API_URL}

WORKDIR /base
COPY .yarn .yarn
Expand Down Expand Up @@ -41,4 +43,4 @@ COPY --from=build /base/.yarnrc.yml .yarnrc.yml
RUN yarn set version 4
RUN yarn install
EXPOSE 5000
CMD [ "yarn", "run", "backend"]
CMD [ "yarn", "workspace", "backend", "start"]
6 changes: 3 additions & 3 deletions backend/src/controller/authentication_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ console.log("redirectUri: %s", REDIRECT_URI);
console.log("clientId: %s", process.env.GOOGLE_ID);

const oAuth2Client = new OAuth2Client({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET,
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
redirectUri: REDIRECT_URI,
});

Expand Down Expand Up @@ -205,7 +205,7 @@ export const googleLoginController = (req: Request, res: Response): void => {
const idToken = req.body.code;

oAuth2Client
.verifyIdToken({ idToken, audience: process.env.GOOGLE_ID })
.verifyIdToken({ idToken, audience: process.env.CLIENT_ID })
.then(response => {
const { email_verified, name, email, picture, sub } = response.getAttributes().payload;
console.log('picture: %s', picture);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/controller/google_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { Event, IntervalSet } from 'common';


const oAuth2Client = new OAuth2Client({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET,
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
redirectUri: `${process.env.API_URL}/google/oauthcallback`,
});
const SCOPES = [
Expand Down
12 changes: 11 additions & 1 deletion k8s/bookme-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ spec:
spec:
containers:
- env:
- name: CLIENT_ID
valueFrom:
secretKeyRef:
key: CLIENT_ID
name: bookme-secret
- name: CLIENT_SECRET
valueFrom:
secretKeyRef:
key: CLIENT_SECRET
name: bookme-secret
- name: API_URL
valueFrom:
configMapKeyRef:
Expand Down Expand Up @@ -73,4 +83,4 @@ spec:
kind: Rule
services:
- name: bookme
port: 5000
port: 5000

0 comments on commit f96caba

Please sign in to comment.