diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..6aff804 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node +{ + "name": "Node.js & TypeScript", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "root" +} diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5d4b3d1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules +pgdata +.env +.devcontainer +docker-compose.yml +Dockerfile +README.md diff --git a/.env.sample b/.env.sample index ea08bfa..451abee 100644 --- a/.env.sample +++ b/.env.sample @@ -25,4 +25,7 @@ PRICE_ID= NEXT_PUBLIC_TRIAL_PERIOD_DAYS= NEXT_PUBLIC_STRIPE_BILLING_PORTAL_URL= BASE_URL=http://localhost:3000 -NEXT_PUBLIC_PRICING= \ No newline at end of file +NEXT_PUBLIC_PRICING= + +# Docker postgres settings +POSTGRES_PASSWORD= diff --git a/.gitignore b/.gitignore index 3cec5f6..e10e251 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ next-env.d.ts /test-results/ /playwright-report/ /playwright/.cache/ + +# docker +pgdata \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6613e0d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# playwright doesnt support debian image +FROM ubuntu:focal + +run apt-get update && apt-get install wget xz-utils -y + +RUN mkdir /data + +WORKDIR /data + +RUN wget https://nodejs.org/dist/v20.5.0/node-v20.5.0-linux-x64.tar.xz -O nodejs.tar.xz \ + && mkdir /opt/nodejs \ + && tar -xf nodejs.tar.xz --strip-components 1 -C /opt/nodejs \ + && rm nodejs.tar.xz +ENV PATH="$PATH:/opt/nodejs/bin" +RUN npm install -g yarn + +COPY ./package.json ./yarn.lock ./playwright.config.ts . + +RUN yarn +RUN npx playwright install-deps + +COPY . . + +RUN yarn prisma generate +RUN yarn build + +CMD yarn prisma migrate deploy && yarn start diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4d2912c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3.5" +services: + linkwarden: + env_file: .env + environment: + - DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/postgres + restart: always + build: . + ports: + - 3000:3000 + volumes: + - /var/lib/elasticsearch/data + postgres: + image: postgres + env_file: .env + restart: always + volumes: + - pgdata:/var/lib/postgresql/data +volumes: + pgdata: