UFF
Signed-off-by: Max Schmidt <max.schmidt@outlook.de>
This commit is contained in:
parent
43fc0a402c
commit
0dfad4431f
5
.env
5
.env
@ -1,5 +0,0 @@
|
||||
MONGODB_URI=mongodb://payload:test@localhost:27017/payload
|
||||
PAYLOAD_SECRET=supersecretkey
|
||||
MONGODB_USER=payload
|
||||
MONGODB_PW=test
|
||||
MONGODB_DB=payload
|
7
.env.development
Normal file
7
.env.development
Normal file
@ -0,0 +1,7 @@
|
||||
MONGODB_URI=mongodb://payload:test@mongo:27017
|
||||
PAYLOAD_SECRET=supersecretkey
|
||||
PAYLOAD_PORT=3001
|
||||
MONGODB_USER=payload
|
||||
MONGODB_PW=test
|
||||
MONGODB_DB=payload
|
||||
NAME=astroad
|
21
astro/Dockerfile
Normal file
21
astro/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
FROM node:lts-alpine as base
|
||||
WORKDIR /base
|
||||
COPY ./package.json ./package.json
|
||||
RUN yarn install
|
||||
COPY ./ ./
|
||||
|
||||
FROM base AS dev
|
||||
ENV NODE_ENV=development
|
||||
EXPOSE 3000
|
||||
CMD ["yarn","dev"]
|
||||
|
||||
FROM base AS build
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /build
|
||||
COPY --from=base /base ./
|
||||
ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache
|
||||
RUN yarn build
|
||||
|
||||
FROM nginx:stable AS prod
|
||||
COPY --from=build /build/dist /usr/share/nginx/html
|
||||
EXPOSE 80
|
@ -3,13 +3,10 @@
|
||||
"type": "module",
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"start": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"astro": "astro"
|
||||
"dev": "astro dev --host",
|
||||
"build": "astro build"
|
||||
},
|
||||
"dependencies": {
|
||||
"astro": "^2.4.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,20 @@
|
||||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
import Card from '../components/Card.astro';
|
||||
import type { Post } from '../../../types';
|
||||
import type { Post } from '../types';
|
||||
|
||||
const posts: Post[] = (await(await fetch("http://localhost:3001/api/posts")).json()).docs;
|
||||
const posts: Post[] = (await(await fetch("http://payload:3001/api/posts")).json()).docs;
|
||||
posts.forEach(post=> console.log(post.title));
|
||||
---
|
||||
|
||||
<Layout title="Welcome to Astro.">
|
||||
<main>
|
||||
{posts.reverse().map(post => (
|
||||
<article>
|
||||
<h2>{post.title}</h2>
|
||||
<p>{post.updatedAt}</p>
|
||||
</article>
|
||||
))}
|
||||
<h1>Welcome to <span class="text-gradient">Astro</span></h1>
|
||||
<p class="instructions">
|
||||
To get started, open the directory <code>src/pages</code> in your project.<br />
|
||||
|
0
types.ts → astro/src/types.ts
Normal file → Executable file
0
types.ts → astro/src/types.ts
Normal file → Executable file
7
deno.json
Normal file
7
deno.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"tasks": {
|
||||
"dev": "docker compose -f docker-compose.yml -f docker-compose-dev.yml --env-file .env.development up -d",
|
||||
"prod": "docker compose -f docker-compose.yml -f docker-compose-prod.yml --env-file .env.production up -d --build",
|
||||
"dump": "docker exec -i astrotus_database /bin/sh -c 'PGPASSWORD=password pg_dump --username directus directus' > ./dump.sql"
|
||||
}
|
||||
}
|
24
docker-compose-dev.yml
Normal file
24
docker-compose-dev.yml
Normal file
@ -0,0 +1,24 @@
|
||||
services:
|
||||
astro:
|
||||
build:
|
||||
context: astro
|
||||
target: dev
|
||||
volumes:
|
||||
- ./astro/src:/base/src
|
||||
- .env.development:/base/.env.development
|
||||
ports:
|
||||
- 3000:3000
|
||||
|
||||
payload:
|
||||
build:
|
||||
context: payload
|
||||
target: dev
|
||||
volumes:
|
||||
- ./payload/src:/base/src
|
||||
- ./astro/src/types.ts:/types.ts
|
||||
ports:
|
||||
- 3001:3001
|
||||
|
||||
mongo:
|
||||
ports:
|
||||
- 27017:27017
|
@ -1,9 +1,11 @@
|
||||
services:
|
||||
astro:
|
||||
build:
|
||||
context: ./astro
|
||||
dockerfile: Dockerfile
|
||||
container_name: ${NAME}-astro
|
||||
restart: unless-stopped
|
||||
|
||||
payload:
|
||||
container_name: ${NAME}_cms
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: ./payload
|
||||
dockerfile: Dockerfile
|
||||
@ -12,7 +14,6 @@ services:
|
||||
environment:
|
||||
MONGODB_URI: ${MONGODB_URI}
|
||||
PORT: ${PAYLOAD_PORT}
|
||||
NODE_ENV: ${NODE_ENV}
|
||||
PAYLOAD_SECRET: ${PAYLOAD_SECRET}
|
||||
mongo:
|
||||
image: mongo:6.0.5
|
||||
@ -23,5 +24,3 @@ services:
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USER}
|
||||
MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PW}
|
||||
ports:
|
||||
- 27017:27017
|
||||
|
27
payload/Dockerfile
Normal file
27
payload/Dockerfile
Normal file
@ -0,0 +1,27 @@
|
||||
FROM node:lts-alpine as base
|
||||
WORKDIR /base
|
||||
COPY ./package.json ./package.json
|
||||
RUN yarn install
|
||||
COPY ./ ./
|
||||
|
||||
FROM base AS dev
|
||||
ENV NODE_ENV=development
|
||||
EXPOSE 3001
|
||||
CMD ["yarn","dev"]
|
||||
|
||||
|
||||
FROM base AS build
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /build
|
||||
COPY --from=base /base ./
|
||||
RUN yarn build
|
||||
|
||||
FROM build as prod
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /prod
|
||||
COPY package.json ./
|
||||
RUN yarn install --production
|
||||
COPY --from=buil /build/dist ./dist
|
||||
COPY --from=buil /build/build ./build
|
||||
EXPOSE 3000
|
||||
CMD ["node", "dist/server.js"]
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"ext": "ts",
|
||||
"exec": "ts-node src/server.ts"
|
||||
"exec": "yarn generate:types && ts-node src/server.ts"
|
||||
}
|
||||
|
@ -1,62 +1,62 @@
|
||||
import { CollectionConfig } from 'payload/types';
|
||||
import { CollectionConfig } from "payload/types";
|
||||
|
||||
const Posts: CollectionConfig = {
|
||||
slug: 'posts',
|
||||
slug: "posts",
|
||||
admin: {
|
||||
defaultColumns: ['title', 'author', 'category', 'tags', 'status'],
|
||||
useAsTitle: 'title',
|
||||
defaultColumns: ["title", "author", "category", "tags", "status"],
|
||||
useAsTitle: "title",
|
||||
},
|
||||
access: {
|
||||
read: () => true,
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'title',
|
||||
type: 'text',
|
||||
name: "title",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
name: 'author',
|
||||
type: 'relationship',
|
||||
relationTo: 'users',
|
||||
name: "author",
|
||||
type: "relationship",
|
||||
relationTo: "users",
|
||||
},
|
||||
{
|
||||
name: 'publishedDate',
|
||||
type: 'date',
|
||||
name: "publishedDate",
|
||||
type: "date",
|
||||
},
|
||||
{
|
||||
name: 'category',
|
||||
type: 'relationship',
|
||||
relationTo: 'categories'
|
||||
name: "category",
|
||||
type: "relationship",
|
||||
relationTo: "categories",
|
||||
},
|
||||
{
|
||||
name: 'tags',
|
||||
type: 'relationship',
|
||||
relationTo: 'tags',
|
||||
name: "tags",
|
||||
type: "relationship",
|
||||
relationTo: "tags",
|
||||
hasMany: true,
|
||||
},
|
||||
{
|
||||
name: 'content',
|
||||
type: 'richText'
|
||||
name: "content",
|
||||
type: "richText",
|
||||
},
|
||||
{
|
||||
name: 'status',
|
||||
type: 'select',
|
||||
name: "status",
|
||||
type: "select",
|
||||
options: [
|
||||
{
|
||||
value: 'draft',
|
||||
label: 'Draft',
|
||||
value: "draft",
|
||||
label: "Draft",
|
||||
},
|
||||
{
|
||||
value: 'published',
|
||||
label: 'Published',
|
||||
value: "published",
|
||||
label: "Published",
|
||||
},
|
||||
],
|
||||
defaultValue: 'draft',
|
||||
defaultValue: "draft",
|
||||
admin: {
|
||||
position: 'sidebar',
|
||||
}
|
||||
}
|
||||
position: "sidebar",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
};
|
||||
|
||||
export default Posts;
|
||||
export default Posts;
|
||||
|
@ -12,6 +12,6 @@ export default buildConfig({
|
||||
},
|
||||
collections: [Categories, Posts, Tags, Users],
|
||||
typescript: {
|
||||
outputFile: path.resolve("../", "types.ts"),
|
||||
outputFile: path.resolve("/", "types.ts"),
|
||||
},
|
||||
});
|
||||
|
1
src/env.d.ts
vendored
Normal file
1
src/env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="astro/client" />
|
Loading…
Reference in New Issue
Block a user