Skip to content

Instantly share code, notes, and snippets.

@slinkardbrandon
Last active Dec 23, 2021
Embed
What would you like to do?
Serverless in docker example
version: '3.7'
services:
appName:
build: { context: . }
ports: ['3000:3000', '3002:3002']
FROM node:12-alpine
WORKDIR /app
COPY tsconfig.json ./
COPY serverless.yml ./
COPY package.json ./
COPY package-lock.json ./
RUN npm ci
COPY . .
EXPOSE 3000
EXPOSE 3002
CMD ["node", "./node_modules/serverless/bin/serverless.js", "offline", "start", "--host", "0.0.0.0"]
@slinkardbrandon
Copy link
Author

slinkardbrandon commented Jan 15, 2021

If you have any issues with connecting to your database with environment variables you also might have to update your connection string in the docker-compose file like so:

  appName:
    build: { context: . }
    ports: ['3000:3000', '3002:3002']
    environment:
-      TYPEORM_URL: postgres://user:pass@localhost/dbName
+      TYPEORM_URL: postgres://user:pass@postgres/dbName

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment