Skip to content

Instantly share code, notes, and snippets.

@Akhu
Last active February 8, 2022 10:37
Show Gist options
  • Save Akhu/9a925c21ee062bc196953da4442f10b5 to your computer and use it in GitHub Desktop.
Save Akhu/9a925c21ee062bc196953da4442f10b5 to your computer and use it in GitHub Desktop.
Svelte Deployment via Docker with PGSSQL
version: '3'
services:
strapi:
image: strapi/strapi
environment:
DATABASE_CLIENT: postgres
DATABASE_NAME: strapi
DATABASE_HOST: postgres
DATABASE_PORT: 5432
DATABASE_USERNAME: strapi
DATABASE_PASSWORD: strapi
volumes:
- ./app:/srv/app
depends_on:
- postgres
svelte:
build: .
platform: linux/x86_64
environment:
STRAPI_URL: http://strapi
postgres:
image: postgres
environment:
POSTGRES_DB: strapi
POSTGRES_USER: strapi
POSTGRES_PASSWORD: strapi
volumes:
- ./data:/var/lib/postgresql/data
# Svelte DockerFile
FROM node:14.17.6-alpine
#To fix the node-gyp rebuild error
RUN apk add --no-cache --virtual .gyp python make g++
# install dependencies
WORKDIR /app
COPY package.json package-lock.json ./
#TODO : npm install --production
RUN npm install
RUN apk del .gyp
# Copy all local files into the image.
COPY . .
RUN npm run build
###
# Only copy over the Node pieces we need
# ~> Saves 35MB
###
FROM node:14.17.6-slim
WORKDIR /app
COPY --from=0 /app .
COPY . .
EXPOSE 3000
CMD ["node", "./build"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment