Skip to content

Commit

Permalink
Merge pull request #467 from waldo-vision/postgres-migrate
Browse files Browse the repository at this point in the history
migrate to postgres provider
  • Loading branch information
Huskydog9988 committed Dec 23, 2023
2 parents 8e18e8e + c9673b8 commit 1c30740
Show file tree
Hide file tree
Showing 19 changed files with 230 additions and 263 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,24 @@ jobs:
run: yarn install

# See https://stackoverflow.com/questions/73648218/github-action-setup-secure-cockroachdb
- name: Start a single CockroachDB instance
- name: Start Postgres instance
run: |
docker compose up -d
sudo apt update && sudo apt install wait-for-it -y
wait-for-it -h localhost -p 26257
wait-for-it -h localhost -p 5432

- name: Build server
run: yarn turbo run build --filter=web...

- name: Run migrations
env:
DATABASE_URL: postgresql://root@localhost:26257?sslmode=disable
DATABASE_URL: postgresql://waldo:waldo@localhost:5432/waldo
run: |
yarn turbo run db:push

- name: Run tests
env:
DATABASE_URL: postgresql://root@localhost:26257?sslmode=disable
DATABASE_URL: postgresql://waldo:waldo@localhost:5432/waldo
WALDO_URI: http://localhost:3000
DISABLE_VERIFY_AUTH: '1'
NEXTAUTH_URL: http://localhost:3000
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
Expand Down
9 changes: 8 additions & 1 deletion apps/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV INFISICAL_ENV prod
ENV INFISICAL_DISABLE_UPDATE_CHECK true

# Install infisical
RUN apk add --no-cache bash curl && curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | bash \
&& apk add infisical

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
Expand All @@ -64,4 +71,4 @@ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public

CMD node apps/web/server.js
CMD ["infisical", "run", "--env", "${INFISICAL_ENV}", "--", "node", "apps/web/server.js"]
3 changes: 3 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ services:
- 3000:3000
env_file:
- ./apps/web/.env
depends_on:
migrate:
condition: service_completed_successfully

migrate:
container_name: migrate
Expand Down
31 changes: 10 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
version: '3.8'

services:
cockroach:
image: cockroachdb/cockroach:latest-v22.2
command: start-single-node --insecure
postgres:
image: postgres:16
environment:
POSTGRES_USER: waldo
POSTGRES_PASSWORD: waldo
POSTGRES_DB: waldo
ports:
# postgres
- 26257:26257
# ui
- 8081:8080
volumes:
- './docker/cockroach/data:/cockroach/cockroach-data:Z'
ulimits:
nofile: 2048
- 5432:5432

redis:
image: redis
adminer:
image: adminer
ports:
- '6379:6379'

serverless-redis-http:
ports:
- '8079:80'
image: hiett/serverless-redis-http:latest
volumes:
- ./docker/http-redis/conf:/app/srh-config/tokens.json
- 8080:8080
4 changes: 0 additions & 4 deletions docker/cockroach/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions docker/https-redis/conf/tokens.json

This file was deleted.

9 changes: 8 additions & 1 deletion packages/database/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ FROM node:18-alpine3.17 AS runner
# set workdir
WORKDIR /app
ENV NODE_ENV production
ENV INFISICAL_ENV prod
ENV INFISICAL_DISABLE_UPDATE_CHECK true

# Install infisical
RUN apk add --no-cache bash curl && curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | bash \
&& apk add infisical

# Copy node_modules from installer to runner
COPY .yarn/releases .yarn/releases
Expand All @@ -28,4 +35,4 @@ COPY --from=builder /app/out/full/ .

ENV Mode migrate

ENTRYPOINT ["sh", "./packages/database/entrypoint.sh"]
CMD ["infisical", "run", "--env", "${INFISICAL_ENV}", "--", "sh", "./packages/database/entrypoint.sh"]
145 changes: 0 additions & 145 deletions packages/database/prisma/migrations/20230113020506_init/migration.sql

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1c30740

Please sign in to comment.