mirror of
https://github.com/lingble/twenty.git
synced 2025-11-02 13:47:55 +00:00
Build render (#2188)
* Build for arm and amd * Add scripts * Add scripts
This commit is contained in:
@@ -60,7 +60,7 @@ export const Favorites = () => {
|
|||||||
draggableItems={
|
draggableItems={
|
||||||
<>
|
<>
|
||||||
{favorites.map((favorite, index) => {
|
{favorites.map((favorite, index) => {
|
||||||
const { id, person, company } = favorite;
|
const { id, person, company, position } = favorite;
|
||||||
return (
|
return (
|
||||||
<DraggableItem
|
<DraggableItem
|
||||||
key={id}
|
key={id}
|
||||||
@@ -68,6 +68,7 @@ export const Favorites = () => {
|
|||||||
index={index}
|
index={index}
|
||||||
itemComponent={
|
itemComponent={
|
||||||
<>
|
<>
|
||||||
|
{position}
|
||||||
{person && (
|
{person && (
|
||||||
<NavItem
|
<NavItem
|
||||||
key={id}
|
key={id}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export const useFavorites = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (destIndex === favorites.length - 1) {
|
if (destIndex === favorites.length - 1) {
|
||||||
return favorites[destIndex].position + 1;
|
return favorites[destIndex - 1].position + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceIndex < destIndex) {
|
if (sourceIndex < destIndex) {
|
||||||
|
|||||||
29
infra/build/front/Dockerfile
Normal file
29
infra/build/front/Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
FROM node:18.16.0-alpine as build
|
||||||
|
|
||||||
|
ARG REACT_APP_SERVER_BASE_URL
|
||||||
|
ARG REACT_APP_SERVER_AUTH_URL
|
||||||
|
ARG REACT_APP_SERVER_FILES_URL
|
||||||
|
|
||||||
|
COPY ./packages/ /app/packages
|
||||||
|
|
||||||
|
WORKDIR /app/front
|
||||||
|
COPY ./front .
|
||||||
|
|
||||||
|
RUN yarn install
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
COPY ./infra/build/front/serve.json ./build
|
||||||
|
|
||||||
|
FROM node:18.16.0-alpine as front
|
||||||
|
|
||||||
|
WORKDIR /app/front
|
||||||
|
|
||||||
|
COPY --from=build /app/front/build ./build
|
||||||
|
COPY ./front/scripts/inject-runtime-env.sh /app/front/scripts/inject-runtime-env.sh
|
||||||
|
|
||||||
|
RUN yarn global add serve
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.source=https://github.com/twentyhq/twenty
|
||||||
|
LABEL org.opencontainers.image.description="This image provides a consistent and reproducible environment for the frontend."
|
||||||
|
|
||||||
|
CMD ["/bin/sh", "-c", "/app/front/scripts/inject-runtime-env.sh && serve build"]
|
||||||
30
infra/build/postgres/Dockerfile
Normal file
30
infra/build/postgres/Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
ARG PG_MAIN_VERSION=14
|
||||||
|
|
||||||
|
FROM postgres:${PG_MAIN_VERSION} as postgres
|
||||||
|
|
||||||
|
ARG PG_MAIN_VERSION
|
||||||
|
ARG PG_GRAPHQL_VERSION=1.3.0
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
ARCH="$(dpkg --print-architecture)"; \
|
||||||
|
case "${ARCH}" in \
|
||||||
|
aarch64|arm64) \
|
||||||
|
TARGETARCH='arm64'; \
|
||||||
|
;; \
|
||||||
|
amd64|x86_64) \
|
||||||
|
TARGETARCH='amd64'; \
|
||||||
|
;; \
|
||||||
|
*) \
|
||||||
|
echo "Unsupported arch: ${ARCH}"; \
|
||||||
|
exit 1; \
|
||||||
|
;; \
|
||||||
|
esac;
|
||||||
|
|
||||||
|
RUN apt update && apt install -y curl
|
||||||
|
|
||||||
|
# Install precompiled pg_graphql extensions
|
||||||
|
RUN curl -L "https://github.com/supabase/pg_graphql/releases/download/v${PG_GRAPHQL_VERSION}/pg_graphql-v${PG_GRAPHQL_VERSION}-pg${PG_MAIN_VERSION}-${TARGETARCH}-linux-gnu.deb" -o pg_graphql.deb
|
||||||
|
RUN dpkg --install pg_graphql.deb
|
||||||
|
|
||||||
|
COPY ./infra/prod/postgres/init.sql /docker-entrypoint-initdb.d/
|
||||||
10
infra/build/postgres/init.sql
Normal file
10
infra/build/postgres/init.sql
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
SELECT 'CREATE DATABASE "default"'
|
||||||
|
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'default')\gexec
|
||||||
|
|
||||||
|
SELECT 'CREATE DATABASE "test"'
|
||||||
|
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'test')\gexec
|
||||||
|
|
||||||
|
SELECT 'CREATE USER twenty PASSWORD ''twenty'''
|
||||||
|
WHERE NOT EXISTS (SELECT FROM pg_user WHERE usename = 'twenty')\gexec
|
||||||
|
|
||||||
|
SELECT 'ALTER ROLE twenty superuser'\gexec
|
||||||
17
infra/build/server/Dockerfile
Normal file
17
infra/build/server/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM node:18.16.0-alpine as build
|
||||||
|
|
||||||
|
WORKDIR /app/server
|
||||||
|
COPY ./server/package.json ./
|
||||||
|
COPY ./server/yarn.lock ./
|
||||||
|
COPY ./server/patches ./patches
|
||||||
|
RUN yarn install
|
||||||
|
|
||||||
|
COPY ./server .
|
||||||
|
RUN npx prisma generate
|
||||||
|
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.source=https://github.com/twentyhq/twenty
|
||||||
|
LABEL org.opencontainers.image.description="This image provides a consistent and reproducible environment for the backend, ensuring it deploys faster and runs the same way regardless of the deployment environment."
|
||||||
|
|
||||||
|
CMD ["node", "dist/src/main"]
|
||||||
@@ -1,29 +1,3 @@
|
|||||||
FROM node:18.16.0-alpine as build
|
FROM --platform=linux/amd64 twentycrm/twenty-front as front
|
||||||
|
|
||||||
ARG REACT_APP_SERVER_BASE_URL
|
|
||||||
ARG REACT_APP_SERVER_AUTH_URL
|
|
||||||
ARG REACT_APP_SERVER_FILES_URL
|
|
||||||
|
|
||||||
COPY ./packages/ /app/packages
|
|
||||||
|
|
||||||
WORKDIR /app/front
|
|
||||||
COPY ./front .
|
|
||||||
|
|
||||||
RUN yarn install
|
|
||||||
RUN yarn build
|
|
||||||
|
|
||||||
COPY ./infra/prod/front/serve.json ./build
|
|
||||||
|
|
||||||
FROM node:18.16.0-alpine as front
|
|
||||||
|
|
||||||
WORKDIR /app/front
|
|
||||||
|
|
||||||
COPY --from=build /app/front/build ./build
|
|
||||||
COPY ./front/scripts/inject-runtime-env.sh /app/front/scripts/inject-runtime-env.sh
|
|
||||||
|
|
||||||
RUN yarn global add serve
|
|
||||||
|
|
||||||
LABEL org.opencontainers.image.source=https://github.com/twentyhq/twenty
|
|
||||||
LABEL org.opencontainers.image.description="This image provides a consistent and reproducible environment for the frontend."
|
|
||||||
|
|
||||||
CMD ["/bin/sh", "-c", "/app/front/scripts/inject-runtime-env.sh && serve build"]
|
CMD ["/bin/sh", "-c", "/app/front/scripts/inject-runtime-env.sh && serve build"]
|
||||||
|
|||||||
@@ -1,23 +1,3 @@
|
|||||||
FROM node:18.16.0-alpine as build
|
FROM --platform=linux/amd64 twentycrm/twenty-server as server
|
||||||
|
|
||||||
WORKDIR /app/server
|
|
||||||
COPY ./server/package.json ./
|
|
||||||
COPY ./server/yarn.lock ./
|
|
||||||
COPY ./server/patches ./patches
|
|
||||||
RUN yarn install
|
|
||||||
|
|
||||||
COPY ./server .
|
|
||||||
RUN npx prisma generate
|
|
||||||
|
|
||||||
RUN yarn build
|
|
||||||
|
|
||||||
FROM node:18.16.0-alpine as server
|
|
||||||
|
|
||||||
COPY --from=build /app/server/dist ./dist
|
|
||||||
|
|
||||||
WORKDIR /app/server
|
|
||||||
|
|
||||||
LABEL org.opencontainers.image.source=https://github.com/twentyhq/twenty
|
|
||||||
LABEL org.opencontainers.image.description="This image provides a consistent and reproducible environment for the backend, ensuring it deploys faster and runs the same way regardless of the deployment environment."
|
|
||||||
|
|
||||||
CMD ["node", "dist/src/main"]
|
CMD ["node", "dist/src/main"]
|
||||||
|
|||||||
5
infra/release/build-front.sh
Executable file
5
infra/release/build-front.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
docker buildx build \
|
||||||
|
--push \
|
||||||
|
--platform linux/amd64,linux/arm64 \
|
||||||
|
-f ./infra/build/front/Dockerfile -t twentycrm/twenty-front:0.1.5 -t twentycrm/twenty-front:latest .
|
||||||
5
infra/release/build-server.sh
Executable file
5
infra/release/build-server.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
docker buildx build \
|
||||||
|
--push \
|
||||||
|
--platform linux/amd64,linux/arm64 \
|
||||||
|
-f ./infra/build/server/Dockerfile -t twentycrm/twenty-server:0.1.5 -t twentycrm/twenty-server:latest .
|
||||||
@@ -14,7 +14,7 @@ services:
|
|||||||
name: server
|
name: server
|
||||||
env: docker
|
env: docker
|
||||||
dockerfilePath: ./infra/prod/server/Dockerfile
|
dockerfilePath: ./infra/prod/server/Dockerfile
|
||||||
dockerCommand: "sh -c ./scripts/compute-database-url.sh && yarn prisma:migrate && yarn database:setup && node dist/src/main"
|
dockerCommand: "sh -c ./scripts/render-run.sh"
|
||||||
autoDeploy: false
|
autoDeploy: false
|
||||||
envVars:
|
envVars:
|
||||||
- key: FRONT_BASE_URL
|
- key: FRONT_BASE_URL
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
export PG_DATABASE_URL=postgres://twenty:twenty@$PG_DATABASE_HOST:$PG_DATABASE_PORT/default
|
|
||||||
5
server/scripts/render-run.sh
Executable file
5
server/scripts/render-run.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
export PG_DATABASE_URL=postgres://twenty:twenty@$PG_DATABASE_HOST:$PG_DATABASE_PORT/default
|
||||||
|
yarn prisma:migrate
|
||||||
|
yarn database:setup
|
||||||
|
node dist/src/main
|
||||||
Reference in New Issue
Block a user