Skip to content

Instantly share code, notes, and snippets.

@jaysson
Created January 28, 2024 09:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaysson/67c7849fa0a5ef633a4bec921dac30a0 to your computer and use it in GitHub Desktop.
Save jaysson/67c7849fa0a5ef633a4bec921dac30a0 to your computer and use it in GitHub Desktop.
Docker setup for AdonisJS V6
FROM node:lts-alpine3.19 AS builder
COPY ./package.json /app/package.json
COPY ./package-lock.json /app/package-lock.json
WORKDIR /app
RUN npm install
COPY ./ /app
RUN npm run build
FROM node:lts-alpine3.19
RUN apk add nginx
COPY --from=builder /app/package.json /app/package.json
COPY --from=builder /app/package-lock.json /app/package-lock.json
WORKDIR /app
RUN npm ci --omit dev
COPY --from=builder /app/build /app
COPY deploy/site.conf /etc/nginx/http.d/default.conf
COPY --chmod=0755 deploy/startup.sh /app/startup.sh
ENV APP_KEY=
ENV PORT=3333
ENV HOST=0.0.0.0
ENV NODE_ENV=production
ENV LOG_LEVEL=info
ENV CACHE_VIEWS=false
ENV SESSION_DRIVER=cookie
EXPOSE 80
ENTRYPOINT ["/app/startup.sh"]
# Path: deploy/site.conf
server {
listen 80;
listen [::]:80;
root /app/public;
charset utf-8;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
location / {
try_files $uri @node;
}
location @node {
proxy_pass http://localhost:3333;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
}
#!/bin/sh
# Path - deploy/startup.sh
cd /app
node bin/console.js migration:run --force
nginx;
node bin/server.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment