GithubHelp home page GithubHelp logo

dockerfile support about agency-os HOT 2 CLOSED

johnykes avatar johnykes commented on August 18, 2024
dockerfile support

from agency-os.

Comments (2)

johnykes avatar johnykes commented on August 18, 2024 1

Just managed to successfully host it on Docker 😁

steps:

  • replace the deprecated nuxt-simple-sitemap with @nuxtjs/sitemap

  • uncomment in nuxt.config.ts

	routeRules: {
		'/**': {
			prerender: true,
		},
	},
  • dockerfile
# build stage
FROM node:18-alpine as build-stage
WORKDIR /app

COPY package.json .
COPY pnpm-lock.yaml ./

RUN apk update
RUN apk add --no-cache git

RUN npm install -g [email protected]

RUN pnpm install

COPY . .

# ENV
ENV DIRECTUS_URL=${DIRECTUS_URL}
ENV DIRECTUS_SERVER_TOKEN=${DIRECTUS_SERVER_TOKEN}
ENV SITE_URL=${SITE_URL}

RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm build

# production stage
FROM node:18-slim as production

COPY --from=build-stage /app/.output /app/.output
COPY --from=build-stage /app/node_modules /app/node_modules

EXPOSE 3000

CMD ["node", "/app/.output/server/index.mjs"]
  • .dockerignore (not working without this, not sure why :) )
node_modules
npm-debug.log
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
  • build

docker build -t test-website --build-arg DIRECTUS_URL='http://host.docker.internal:8055' --build-arg DIRECTUS_SERVER_TOKEN='...' --build-arg SITE_URL='http://localhost:3000' --build-arg NODE_OPTIONS="--max-old-space-size=4096" .

  • start docker container

docker run --name test-website --network directus_default -p 3000:3000 -e "DIRECTUS_URL=http://localhost:8055" -e "DIRECTUS_SERVER_TOKEN=..." -e "SITE_URL=https://your_domain" --rm test-website

PS: in production, the DIRECTUS_URL & SITE_URL can't be localhost
PS 2: in .directus/docker-compose.yml you need to update CORS, else, the forms won't work
CORS_ENABLED: 'true'
CORS_ORIGIN: 'https://mywebsite.com,http://localhost:3000'
CORS_METHODS: GET,POST

from agency-os.

ComfortablyCoding avatar ComfortablyCoding commented on August 18, 2024

Thanks for the info and glad you got it working! As I do not see any issue outlined here I am going to close this for now, happy to re-open if needed.

from agency-os.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.