-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from familab/mjh/feature/publish-tweaks
Improved Deployment
- Loading branch information
Showing
6 changed files
with
115 additions
and
25 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
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,19 +1,35 @@ | ||
FROM node:18-alpine | ||
FROM node:18-alpine as base | ||
LABEL org.opencontainers.image.source = "https://github.com/familab/accessController" | ||
|
||
|
||
FROM base as build_api | ||
# Build API | ||
|
||
RUN npm install --global pnpm | ||
|
||
WORKDIR /home | ||
WORKDIR /build | ||
COPY package.json \ | ||
tsconfig.json \ | ||
pnpm-workspace.yaml \ | ||
./ | ||
|
||
COPY tsconfig.json ./ | ||
WORKDIR /build/api | ||
COPY api/package.json \ | ||
api/tsconfig.json \ | ||
api/tsconfig.build.json \ | ||
api/ | ||
COPY api/src api/src | ||
./ | ||
COPY api/src src/ | ||
|
||
RUN pnpm install | ||
RUN pnpm run build | ||
RUN pnpm \ | ||
--filter=@familab/access-controller.api \ | ||
--prod \ | ||
deploy deployment | ||
|
||
|
||
FROM base | ||
|
||
RUN cd api && \ | ||
pnpm install && \ | ||
pnpm run build | ||
COPY --from=build_api /build/api/deployment ./ | ||
|
||
ENTRYPOINT node ./api/build/server.js | ||
ENTRYPOINT node ./build/server.js |
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,10 +1,3 @@ | ||
<style> | ||
body { | ||
color: #fda501; | ||
background-color: #2b2b2b; | ||
} | ||
</style> | ||
|
||
FamiLAB Access Controller | ||
========================= | ||
|
||
|
@@ -28,6 +21,8 @@ See [nfc/README.md](./nfc/README.md) | |
|
||
See [api/README.md](./api/README.md) | ||
|
||
-------------------------------- | ||
|
||
## Development Setup | ||
|
||
1. Install Node 18+ | ||
|
@@ -41,6 +36,47 @@ See [api/README.md](./api/README.md) | |
``` | ||
4. Follow Development Setup instructions for the sub-project you wish to work on. | ||
|
||
-------------------------------- | ||
|
||
## Deployment Process | ||
|
||
The Docker image is built via GitHub Actions whenever a new commit is merged into the `release/v4` branch. The image is | ||
therefore tagged `ghcr.io/familab/accesscontroller:release-v4`. | ||
|
||
The server application is composed of multiple docker containers defined by the `./access-controller.stack.yml` Docker | ||
Stack. To deploy this file to the server, you must have a Docker Context set up locally, and then update the Stack using | ||
the stack file. | ||
|
||
### Setup Docker Context | ||
|
||
On your local machine, create a new [Docker Context](https://docs.docker.com/engine/context/working-with-contexts/) for | ||
the access controller server. | ||
|
||
```bash | ||
docker context create familab.accesscontroller --docker "host=ssh://[email protected]" | ||
docker context use familab.accesscontroller | ||
``` | ||
|
||
Once you run these commands all `docker *` commands you use will target the remote server. | ||
|
||
You can always switch back to targeting your local machine by running: | ||
|
||
```bash | ||
docker context use default | ||
``` | ||
|
||
### Update Stack | ||
|
||
Once you have a Docker Context set up for the remote server, run the following command to push the Stack. | ||
|
||
```bash | ||
docker stack deploy -c "./access-controller.stack.yml" access-controller | ||
``` | ||
|
||
Make sure to check the logs of the containers to ensure the deployment worked. | ||
|
||
-------------------------------- | ||
|
||
## Project Status | ||
|
||
Currently implementing Phase 0. | ||
|
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,26 @@ | ||
# Docker Swarm Stack | ||
version: "3.9" | ||
|
||
services: | ||
auth_service: | ||
image: ghcr.io/familab/accesscontroller:release-v4 | ||
build: | ||
context: ./ | ||
ports: | ||
- "8080:8080/tcp" | ||
secrets: | ||
- google_credentials_client_email | ||
- google_credentials_private_key | ||
environment: | ||
SERVER_PORT: 8080 | ||
LOGGING.LEVEL: info | ||
GOOGLE.SPREADSHEET_ID: 1Mq3VC8-aO_3UA5PiUksvpzVHU1C49I5I1nvsnFs80Zo | ||
GOOGLE.SPREADSHEET_RANGE: Sheet1 | ||
GOOGLE.CREDENTIALS.CLIENT_EMAIL#file: /run/secrets/google_credentials_client_email | ||
GOOGLE.CREDENTIALS.PRIVATE_KEY#file: /run/secrets/google_credentials_private_key | ||
|
||
secrets: | ||
google_credentials_client_email: | ||
external: true | ||
google_credentials_private_key: | ||
external: true |
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