From c470c4d346c93613a48f587bcb18e9d985c2a604 Mon Sep 17 00:00:00 2001 From: Andy Jiang Date: Tue, 20 Jun 2023 00:27:04 +0200 Subject: [PATCH] docs: add Docker files (#253) * add docker files to repo * original suggestions * use latest deno version --------- Co-authored-by: Asher Gomez --- .dockerignore | 4 ++++ Dockerfile | 8 ++++++++ README.md | 47 +++------------------------------------------- docker-compose.yml | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 44 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..493a0cd60 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +README.md +.example.env +.vscode/ +.github/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..3fecd1a00 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM denoland/deno +EXPOSE 8000 +WORKDIR /app +ADD . /app + +# Add dependencies to the container's Deno cache +RUN deno cache main.ts +CMD ["task", "start"] \ No newline at end of file diff --git a/README.md b/README.md index aa64fbfd8..9fc7f3990 100644 --- a/README.md +++ b/README.md @@ -208,50 +208,9 @@ AWS Lightsail and Digital Ocean. 2. Create an account on [Docker Hub](https://hub.docker.com), a registry for Docker container images. -3. Create a `Dockerfile` in the root of your repo: - - ```docker - FROM denoland/deno:1.32.4 - EXPOSE 8000 - WORKDIR /app - ADD . /app - - # Add dependencies to the container's Deno cache - RUN deno cache main.ts --import-map=import_map.json - CMD ["run", "--allow-run", "--allow-write", "--allow-read", "--allow-env", "--allow-net", "main.ts"] - ``` - -4. Create a `.dockerignore` file in the root folder of your repo to make sure - certain files are not deployed to the docker container: - - ```dockerignore - README.md - .example.env - .vscode/ - .github/ - ``` - -5. A `docker-compose.yml` file will be needed to run the docker file on a VPS. - Here’s what that file in your repo's root folder will look like: - - ```yml - version: '3' - - services: - web: - build: . - container_name: deno-sasskit - image: deno-image - environment: - - DENO_DEPLOYMENT_ID=${DENO_DEPLOYMENT_ID} - - GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID} - - GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET} - - STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY} - - STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET} - - STRIPE_PREMIUM_PLAN_PRICE_ID=${STRIPE_PREMIUM_PLAN_PRICE_ID} - ports: - - "8000:8000" - ``` +> Note: the [`Dockerfile`](./Dockerfile), [`.dockerignore`](./.dockerignore) and +> [`docker-compose.yml`](./docker-compose.yml) files come included with this +> repo. The values of the environmental variables are pulled from the `.env` file. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..8889171c2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3' + + services: + web: + build: . + container_name: deno-saaskit + image: deno-image + environment: + - DENO_DEPLOYMENT_ID=${DENO_DEPLOYMENT_ID} + - GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID} + - GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET} + - STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY} + - STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET} + - STRIPE_PREMIUM_PLAN_PRICE_ID=${STRIPE_PREMIUM_PLAN_PRICE_ID} + ports: + - "8000:8000" \ No newline at end of file