Skip to content

Instantly share code, notes, and snippets.

@slinkardbrandon
Last active June 13, 2023 13:00
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slinkardbrandon/200ad96d5705eb0cb138aee6b534285e to your computer and use it in GitHub Desktop.
Save slinkardbrandon/200ad96d5705eb0cb138aee6b534285e to your computer and use it in GitHub Desktop.
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

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