mirror of
https://github.com/sergeyyarkov/astro-directus-example.git
synced 2026-10-11 10:19:04 +03:00
docker
This commit is contained in:
parent
6f4275d477
commit
a2f85b4275
13
.vscode/settings.json
vendored
Normal file
13
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"sqltools.connections": [
|
||||||
|
{
|
||||||
|
"previewLimit": 50,
|
||||||
|
"server": "localhost",
|
||||||
|
"port": 5432,
|
||||||
|
"driver": "PostgreSQL",
|
||||||
|
"name": "local",
|
||||||
|
"database": "directus",
|
||||||
|
"username": "directus"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
75
compose.dev.yml
Normal file
75
compose.dev.yml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
version: '3.8'
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: ./website
|
||||||
|
target: production
|
||||||
|
network: host
|
||||||
|
extra_hosts:
|
||||||
|
- 'cms.localhost:127.0.0.1'
|
||||||
|
container_name: web
|
||||||
|
volumes:
|
||||||
|
- ./website:/app:rw
|
||||||
|
depends_on:
|
||||||
|
- directus
|
||||||
|
networks:
|
||||||
|
- directus
|
||||||
|
env_file:
|
||||||
|
- ./website/.env
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
# restart: 'always'
|
||||||
|
container_name: nginx
|
||||||
|
image: nginx:1.23.3-alpine
|
||||||
|
volumes:
|
||||||
|
- './nginx/nginx.conf:/etc/nginx/nginx.conf'
|
||||||
|
ports:
|
||||||
|
- '80:80'
|
||||||
|
- '433:433'
|
||||||
|
depends_on:
|
||||||
|
- directus
|
||||||
|
networks:
|
||||||
|
- directus
|
||||||
|
|
||||||
|
database:
|
||||||
|
image: postgres:15-alpine
|
||||||
|
container_name: database
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: directus
|
||||||
|
POSTGRES_PASSWORD: directus
|
||||||
|
POSTGRES_DB: directus
|
||||||
|
volumes:
|
||||||
|
- db-data:/var/lib/postgresql/data
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
networks:
|
||||||
|
- directus
|
||||||
|
|
||||||
|
directus:
|
||||||
|
image: directus/directus:10.0.0
|
||||||
|
ports:
|
||||||
|
- 8055:8055
|
||||||
|
volumes:
|
||||||
|
- uploads:/directus/uploads
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
networks:
|
||||||
|
- directus
|
||||||
|
environment:
|
||||||
|
KEY: '255d861b-5ea1-5996-9aa3-922530ec40b1'
|
||||||
|
SECRET: '6116487b-cda1-52c2-b5b5-c8022c45e263'
|
||||||
|
MAX_PAYLOAD_SIZE: '100mb'
|
||||||
|
DB_CLIENT: 'pg'
|
||||||
|
DB_HOST: 'database'
|
||||||
|
DB_PORT: '5432'
|
||||||
|
DB_DATABASE: 'directus'
|
||||||
|
DB_USER: 'directus'
|
||||||
|
DB_PASSWORD: 'directus'
|
||||||
|
ADMIN_EMAIL: 'admin@example.com'
|
||||||
|
ADMIN_PASSWORD: 'd1r3ctu5'
|
||||||
|
volumes:
|
||||||
|
db-data:
|
||||||
|
uploads:
|
||||||
|
networks:
|
||||||
|
directus:
|
||||||
|
driver: bridge
|
||||||
@ -4,7 +4,6 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./website
|
context: ./website
|
||||||
target: production
|
target: production
|
||||||
network: host
|
|
||||||
container_name: web
|
container_name: web
|
||||||
volumes:
|
volumes:
|
||||||
- './website/nginx/conf.d:/etc/nginx/conf.d:rw'
|
- './website/nginx/conf.d:/etc/nginx/conf.d:rw'
|
||||||
@ -16,18 +15,20 @@ services:
|
|||||||
- directus
|
- directus
|
||||||
- nginx
|
- nginx
|
||||||
environment:
|
environment:
|
||||||
- DIRECTUS_URL=http://localhost:8055
|
- DIRECTUS_URL=http://cms.localhost
|
||||||
- DIRECTUS_EMAIL=admin@example.com
|
- DIRECTUS_EMAIL=admin@example.com
|
||||||
- DIRECTUS_PASSWORD=d1r3ctu5
|
- DIRECTUS_PASSWORD=d1r3ctu5
|
||||||
- DIRECTUS_STATIC_TOKEN=
|
- DIRECTUS_STATIC_TOKEN=
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
|
restart: 'always'
|
||||||
container_name: nginx
|
container_name: nginx
|
||||||
image: nginx:1.23.3-alpine
|
image: nginx:1.23.3-alpine
|
||||||
volumes:
|
volumes:
|
||||||
- './nginx/nginx.conf:/etc/nginx/nginx.conf'
|
- './nginx/nginx.conf:/etc/nginx/nginx.conf'
|
||||||
ports:
|
ports:
|
||||||
- '80:80'
|
- '80:80'
|
||||||
|
- '433:433'
|
||||||
depends_on:
|
depends_on:
|
||||||
- directus
|
- directus
|
||||||
networks:
|
networks:
|
||||||
@ -43,7 +44,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- db-data:/var/lib/postgresql/data
|
- db-data:/var/lib/postgresql/data
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432
|
||||||
networks:
|
networks:
|
||||||
- directus
|
- directus
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ services:
|
|||||||
directus:
|
directus:
|
||||||
image: directus/directus:latest
|
image: directus/directus:latest
|
||||||
ports:
|
ports:
|
||||||
- 8055:8055
|
- 8055
|
||||||
volumes:
|
volumes:
|
||||||
- uploads:/directus/uploads
|
- uploads:/directus/uploads
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@ -23,6 +23,8 @@ http {
|
|||||||
|
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
|
|
||||||
|
resolver 127.0.0.11 valid=30s ipv6=off;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
@ -30,7 +32,8 @@ http {
|
|||||||
server_name localhost;
|
server_name localhost;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://web:80;
|
set $website http://web:80;
|
||||||
|
proxy_pass $website;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection 'upgrade';
|
proxy_set_header Connection 'upgrade';
|
||||||
|
|||||||
0
scripts/rebuild-web.sh
Normal file
0
scripts/rebuild-web.sh
Normal file
@ -1,3 +1,3 @@
|
|||||||
node_modules/
|
./node_modules
|
||||||
uploads/
|
./dist
|
||||||
dist/
|
./.astro
|
||||||
@ -1,11 +1,11 @@
|
|||||||
# syntax=docker/dockerfile:1.0
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
ARG NODE_IMAGE=node:19-alpine3.16
|
ARG NODE_IMAGE=node:19-alpine3.16
|
||||||
ARG NGINX_IMAGE=nginx:1.23.3-alpine
|
ARG NGINX_IMAGE=nginx:1.23.3-alpine
|
||||||
|
|
||||||
|
# DEVELOPMENT STAGE
|
||||||
FROM ${NODE_IMAGE} as development
|
FROM ${NODE_IMAGE} as development
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY ./package.json ./
|
COPY ./package.json ./
|
||||||
COPY ./package-lock.json ./
|
COPY ./package-lock.json ./
|
||||||
|
|
||||||
@ -16,10 +16,13 @@ COPY . .
|
|||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD [ "npm", "start" ]
|
CMD [ "npm", "start" ]
|
||||||
|
|
||||||
|
# BUILDER STAGE
|
||||||
FROM development as builder
|
FROM development as builder
|
||||||
|
ENV DIRECTUS_URL=http://cms.localhost
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
# PRODUCTION STAGE
|
||||||
FROM ${NGINX_IMAGE} as production
|
FROM ${NGINX_IMAGE} as production
|
||||||
|
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|||||||
6
website/lib/directus-collections.d.ts
vendored
6
website/lib/directus-collections.d.ts
vendored
@ -15,9 +15,9 @@ export type ContactsCollection = {
|
|||||||
|
|
||||||
export type ArticleCollection = {
|
export type ArticleCollection = {
|
||||||
id: ID;
|
id: ID;
|
||||||
status: string;
|
status: 'published' | 'draft' | 'archieved';
|
||||||
title: string;
|
title: string;
|
||||||
slug: 'published' | 'draft' | 'archieved';
|
slug: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
cover?: string;
|
cover?: string;
|
||||||
body?: string;
|
body?: string;
|
||||||
@ -34,8 +34,8 @@ export type SettingsCollection = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type DirectusCollections = {
|
export type DirectusCollections = {
|
||||||
|
articles: ArticleCollection;
|
||||||
about_us: AboutUsCollection;
|
about_us: AboutUsCollection;
|
||||||
contacts: ContactsCollection;
|
contacts: ContactsCollection;
|
||||||
articles: ArticleCollection;
|
|
||||||
settings: SettingsCollection;
|
settings: SettingsCollection;
|
||||||
};
|
};
|
||||||
|
|||||||
3575
website/package-lock.json
generated
3575
website/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,10 +10,10 @@
|
|||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/tailwind": "^3.1.0",
|
"@astrojs/tailwind": "^3.1.2",
|
||||||
"@directus/sdk": "^10.3.1",
|
"@directus/sdk": "^10.3.3",
|
||||||
"astro": "^2.1.2",
|
"astro": "^2.4.5",
|
||||||
"astro-icon": "^0.8.0",
|
"astro-icon": "^0.8.0",
|
||||||
"tailwindcss": "^3.2.7"
|
"tailwindcss": "^3.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { Icon } from 'astro-icon';
|
|||||||
const data = await directus.singleton('contacts').read();
|
const data = await directus.singleton('contacts').read();
|
||||||
---
|
---
|
||||||
|
|
||||||
<PageLayout title={data?.heading || 'Contacts'}>
|
<PageLayout title={'Contacts'}>
|
||||||
<div>
|
<div>
|
||||||
<h1>{data?.heading}</h1>
|
<h1>{data?.heading}</h1>
|
||||||
<div set:html={data?.body} />
|
<div set:html={data?.body} />
|
||||||
@ -16,10 +16,12 @@ const data = await directus.singleton('contacts').read();
|
|||||||
<ul class='flex'>
|
<ul class='flex'>
|
||||||
{data.contacts.map((c) => (
|
{data.contacts.map((c) => (
|
||||||
<li class='flex items-center mr-5 italic text-sm mb-1.5'>
|
<li class='flex items-center mr-5 italic text-sm mb-1.5'>
|
||||||
<span class='mr-1.5'>
|
{c.icon && (
|
||||||
<Icon name={c?.icon} height={16} width={16} />
|
<span class='mr-1.5'>
|
||||||
</span>
|
<Icon name={c.icon} height={16} width={16} />
|
||||||
{c?.href_prefix ? (
|
</span>
|
||||||
|
)}
|
||||||
|
{c.href_prefix ? (
|
||||||
<a class='underline' href={`${c.href_prefix}:${c.data}`}>
|
<a class='underline' href={`${c.href_prefix}:${c.data}`}>
|
||||||
{c.data}
|
{c.data}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user