Skip to content

Commit

Permalink
Merge pull request #11 from any-VM/selfhost
Browse files Browse the repository at this point in the history
Add selfhosting steps
  • Loading branch information
skullcrushercmd authored Mar 6, 2024
2 parents 0fd7738 + 9fc3b29 commit b72ff4a
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 55 deletions.
115 changes: 60 additions & 55 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,64 @@ import tailwind from "@astrojs/tailwind";
import codeTheme from "./code-theme.json";
// https://astro.build/config
export default defineConfig({
site: "https://code.anyvm.tech",
integrations: [
starlight({
head: [
{
tag: "meta",
attrs: {
property: "og:image",
content: "https://code.anyvm.tech/logo.png",
},
},
{
tag: "link",
attrs: {
rel: "icon",
href: "/logo.png",
},
},
],
expressiveCode: {
themes: [codeTheme],
},
editLink: {
baseUrl: "https://github.com/any-vm/anycode-docs/edit/main/",
},
favicon: "./src/assets/anycode.svg",
logo: {
src: "./src/assets/anycode.svg",
},
title: "AnyCode",
social: {
github: "https://github.com/any-vm/anycode",
discord: "https://discord.gg/6cpcbKwjBn",
},
sidebar: [
{
label: "Start Here",
// Autogenerate a group of links for the 'guides' directory.
autogenerate: {
directory: "start-here",
},
},
{
label: "Other Info",
autogenerate: {
directory: "other-info",
},
},
],
customCss: ["./src/index.css"],
}),
tailwind({
applyBaseStyles: false,
}),
],
site: "https://code.anyvm.tech",
integrations: [
starlight({
head: [
{
tag: "meta",
attrs: {
property: "og:image",
content: "https://code.anyvm.tech/logo.png",
},
},
{
tag: "link",
attrs: {
rel: "icon",
href: "/logo.png",
},
},
],
expressiveCode: {
themes: [codeTheme],
},
editLink: {
baseUrl: "https://github.com/any-vm/anycode-docs/edit/main/",
},
favicon: "./src/assets/anycode.svg",
logo: {
src: "./src/assets/anycode.svg",
},
title: "AnyCode",
social: {
github: "https://github.com/any-vm/anycode",
discord: "https://discord.gg/6cpcbKwjBn",
},
sidebar: [
{
label: "Start Here",
autogenerate: {
directory: "start-here",
},
},
{
label: "Self Hosting",
autogenerate: {
directory: "self-hosting",
},
},
{
label: "Other Info",
autogenerate: {
directory: "other-info",
},
},
],
customCss: ["./src/index.css"],
}),
tailwind({
applyBaseStyles: false,
}),
],
});
83 changes: 83 additions & 0 deletions src/content/docs/self-hosting/get-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: Get Started
description: How to setup Anycode local server
---

## Setting Up a Local Server

```
npm install -g pnpm
pnpm install
pnpm dev
```

## Configuring .env

Now that you have a working local server, You're going to stop it and now you're going to make a .env file and follow the example below.

```bash
// .env
DATABASE_URL=""
NEXTAUTH_URL=""
NEXTAUTH_SECRET=""
SENDGRID_API=""
EMAIL_FROM=""
EMAIL_SERVER_HOST=""
EMAIL_SERVER_PORT=""
EMAIL_SERVER_USER=""
# This can be changed to a password to any SMTP server
EMAIL_SERVER_PASSWORD=$SENDGRID_API
GITHUB_ID=""
GITHUB_SECRET=""
DISCORD_CLIENT_ID=""
DISCORD_CLIENT_SECRET=""
```

## Values

### General

`DATABASE_URL` is the URL to your database. If you're using a local database, you can use `postgresql://postgres:password@localhost:5432/anycode` as the value.

`NEXTAUTH_URL` is the public URL for your AnyCode instance.

`NEXTAUTH_SECRET` is a randomly generated string that is used to encrypt the email verification tokens. You can generate a string using `openssl rand -base64 32`.

### Email

`SENDGRID_API` can be used if you are using SendGrid to send emails.

`EMAIL_FROM` is the email address that will be used to send emails.

`EMAIL_SERVER_HOST` is the SMTP server host.

`EMAIL_SERVER_PORT` is the SMTP server port.

`EMAIL_SERVER_USER` is the SMTP server username.

`EMAIL_SERVER_PASSWORD` is the SMTP server password.

### OAuth

`GITHUB_ID` is the GitHub OAuth client ID.

`GITHUB_SECRET` is the GitHub OAuth client secret.

`DISCORD_CLIENT_ID` is the Discord OAuth client ID.

`DISCORD_CLIENT_SECRET` is the Discord OAuth client secret.

## Setup

Next, setup PostgreSQL.
You can easily setup a PostgreSQL database using Docker by running `docker run --name anyvm-postgres -p 5432:5432 -e POSTGRES_PASSWORD=replaceme -d postgres`, and updating your env file accordingly.

After you have created the .env file, make sure that your database is running, and run the following commands.

```bash
pnpm install
pnpm db
pnpm build
```

Now you can start the server using `pnpm start`. You should now be able to access your AnyCode instance at localhost:3000, which you can proxy through something such as Nginx or Caddy to make it accessible from the internet.
1 change: 1 addition & 0 deletions src/content/docs/start-here/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Configuring AnyCode
description: How to configure AnyCode
---

# File Configuration
AnyCode is quick and easy when it comes to configuration.

Here is a simple example of how a config file should look
Expand Down

0 comments on commit b72ff4a

Please sign in to comment.