-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is generally an empty project in Nx's eyes, but it does exist for the sole purpose of allowing me to only push up a new postgres image whenever I modify the dockerfile for the unteris postgres image. The reason for the image is to make use of the [ulid][ulid] extension that actually has a true ulid type in postgres and can be translated into timestamps by casting. They're also way faster, which is a big bonus. The dockerfiles have also been split apart again, which, while creating some WET code in terms of the dockerfiles, it does allow for a better separation of concerns of each file, and can probably be used to better improve each file as necessary. The local docker compose file also now uses the local postgres dockerfile instead of the common image, again for the ulid implementation. The docker build executor now takes in these dockerfiles by matching to the project root and builds each image. Seems to be faster as well, but only time will tell when it comes toactually publishing. Speaking of which, I should start running the package non-publish command on CI runs to ensure when I merge to main it will still work as expected. [ulid]: https://github.com/pksunkara/pgx_ulid/
- Loading branch information
Showing
14 changed files
with
178 additions
and
106 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 |
---|---|---|
|
@@ -43,7 +43,7 @@ apps/site/public/images | |
|
||
*.local | ||
*.production | ||
docker/ | ||
docker/* | ||
!libs/docker/ | ||
*.log | ||
dump |
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
FROM node:20.2-alpine3.18 as unteris-node | ||
|
||
RUN npm i -g [email protected] && \ | ||
apk add --no-cache \ | ||
dumb-init=1.2.5-r2 | ||
|
||
FROM unteris-node AS unteris-common | ||
|
||
WORKDIR /src | ||
RUN apk add --no-cache \ | ||
python3 \ | ||
make \ | ||
gcc \ | ||
g++ | ||
COPY package.json \ | ||
tsconfig* \ | ||
nx.json \ | ||
pnpm-lock.yaml \ | ||
./ | ||
ENV CYPRESS_INSTALL_BINARY=0 | ||
RUN pnpm i | ||
|
||
FROM unteris-common AS migrations-build | ||
COPY apps/kysely-cli ./apps/kysely-cli | ||
COPY libs/server ./libs/server | ||
COPY libs/db ./libs/db | ||
COPY libs/shared ./libs/shared/ | ||
RUN pnpm nx run kysely-cli:build:production | ||
|
||
FROM unteris-node AS migrations-prod | ||
LABEL description="The image that runs migrations for the Unteris Database. This should be ran as one-off commands on demand" | ||
USER node | ||
WORKDIR /src | ||
COPY --from=migrations-build --chown=node:node /src/dist ./dist | ||
RUN cp ./dist/apps/kysely-cli/package.json ./package.json | ||
ENV NODE_ENV=production | ||
RUN pnpm i | ||
CMD ["dumb-init", "node", "dist/apps/kysely-cli/main", "migrate"] |
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,21 @@ | ||
FROM postgres:15.3 as postgres-prod | ||
|
||
LABEL description="A custom postgres image that has ulids built in as an extension with binary representation and the ability to retreive the timestamp from them." | ||
|
||
RUN apt update | ||
|
||
RUN apt install -y --no-install-recommends curl ca-certificates | ||
|
||
RUN apt upgrade -y | ||
|
||
RUN curl -OJL https://github.com/pksunkara/pgx_ulid/releases/download/v0.1.1/pgx_ulid-v0.1.1-pg15-$(dpkg --print-architecture)-linux-gnu.deb && \ | ||
apt install ./pgx_ulid-v0.1.1-pg15-$(dpkg --print-architecture)-linux-gnu.deb | ||
|
||
WORKDIR /home/postgres | ||
|
||
ENV HOME=/home/postgres | ||
ENV PATH=/home/postgres/.cargo/bin:$PATH | ||
|
||
RUN chown postgres:postgres /home/postgres | ||
|
||
USER postgres |
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,23 @@ | ||
{ | ||
"name": "postgres", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "apps/postgres", | ||
"projectType": "application", | ||
"targets": { | ||
"lint": { | ||
"executor": "nx:noop" | ||
}, | ||
"package": { | ||
"executor": "@unteris/plugin/docker:build", | ||
"outputs": ["docker/cache/postgres"], | ||
"opitons": {}, | ||
"inputs": ["{projectRoot}/Dockerfile"], | ||
|
||
"configurations": { | ||
"ci": { | ||
"publish": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM node:20.2-alpine3.18 as unteris-node | ||
|
||
|
||
RUN npm i -g [email protected] && \ | ||
apk add --no-cache \ | ||
dumb-init=1.2.5-r2 | ||
|
||
FROM unteris-node AS unteris-common | ||
|
||
WORKDIR /src | ||
RUN apk add --no-cache \ | ||
python3 \ | ||
make \ | ||
gcc \ | ||
g++ | ||
COPY package.json \ | ||
tsconfig* \ | ||
nx.json \ | ||
pnpm-lock.yaml \ | ||
./ | ||
ENV CYPRESS_INSTALL_BINARY=0 | ||
RUN pnpm i | ||
|
||
FROM unteris-common AS server-build | ||
COPY apps/server ./apps/server/ | ||
COPY libs/server ./libs/server/ | ||
COPY libs/shared ./libs/shared/ | ||
RUN pnpm nx run server:build:production | ||
|
||
FROM unteris-node AS server-prod | ||
LABEL description="The server side code for the Unteris website. It runs a NestJS server and connects to a redis and postgres database" | ||
USER node | ||
WORKDIR /src | ||
COPY --from=server-build --chown=node:node /src/dist/apps/server ./ | ||
ENV NODE_ENV=production | ||
RUN pnpm i | ||
CMD ["dumb-init", "node", "main.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM node:20.2-alpine3.18 as unteris-node | ||
|
||
|
||
RUN npm i -g [email protected] && \ | ||
apk add --no-cache \ | ||
dumb-init=1.2.5-r2 | ||
|
||
FROM unteris-node AS unteris-common | ||
|
||
WORKDIR /src | ||
RUN apk add --no-cache \ | ||
python3 \ | ||
make \ | ||
gcc \ | ||
g++ | ||
COPY package.json \ | ||
tsconfig* \ | ||
nx.json \ | ||
pnpm-lock.yaml \ | ||
./ | ||
ENV CYPRESS_INSTALL_BINARY=0 | ||
RUN pnpm i | ||
|
||
FROM unteris-common AS site-build | ||
WORKDIR /src | ||
COPY apps/site ./apps/site | ||
COPY libs/ui ./libs/ui | ||
COPY libs/shared ./libs/shared/ | ||
RUN VITE_SERVER_URL="https://api.unteris.com" pnpm nx run site:build:production | ||
|
||
FROM caddy:2.6.4-alpine as site-prod | ||
LABEL description="The Unteris website image, ran via a Caddy reverse proxy" | ||
WORKDIR /src | ||
COPY apps/site/robots.txt ./dist/apps/site/robots.txt | ||
COPY --from=site-build /src/dist/apps/site/ ./dist/apps/site | ||
COPY Caddyfile ./Caddyfile | ||
CMD ["caddy", "run", "--config", "Caddyfile"] |
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
This file was deleted.
Oops, something went wrong.
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