Added Dockerfile for standalone image
parent
65634c75b9
commit
eb9a891807
@ -0,0 +1,20 @@
|
||||
**
|
||||
|
||||
!/nginx
|
||||
|
||||
!/entrypoint.sh
|
||||
|
||||
!/packages/server/src
|
||||
!/packages/server/package.json
|
||||
!/packages/server/yarn.lock
|
||||
!/packages/server/tsconfig.build.json
|
||||
!/packages/server/tsconfig.json
|
||||
|
||||
!/packages/client/src
|
||||
!/packages/client/index.html
|
||||
!/packages/client/splashscreen.html
|
||||
!/packages/client/tsconfig.json
|
||||
!/packages/client/tsconfig.node.json
|
||||
!/packages/client/vite.config.ts
|
||||
!/packages/client/package.json
|
||||
!/packages/client/yarn.lock
|
@ -0,0 +1,39 @@
|
||||
name: Deploy Standalone
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Deploy Client", "Deploy Server"]
|
||||
branches: [main]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
name: Build Docker image
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
steps:
|
||||
- name: Setup
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
# Login
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: guusvanmeerveld
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# Build & Push
|
||||
- name: Build Dockerfile and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
context: .
|
||||
tags: guusvanmeerveld/dust-mail:standalone
|
||||
|
||||
# Cache
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
@ -0,0 +1,60 @@
|
||||
#
|
||||
# This Dockerfile combines both the client and the server into a single container
|
||||
#
|
||||
|
||||
ARG BASE_IMAGE=node:12-alpine
|
||||
|
||||
# Build client
|
||||
FROM $BASE_IMAGE AS client-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./packages/client .
|
||||
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
ENV NODE_ENV "production"
|
||||
|
||||
ENV VITE_DEFAULT_SERVER "/api"
|
||||
|
||||
ENV VITE_APP_NAME "Dust-Mail"
|
||||
|
||||
RUN yarn build
|
||||
|
||||
# Build server
|
||||
FROM $BASE_IMAGE AS server-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./packages/server .
|
||||
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
RUN yarn build
|
||||
|
||||
RUN yarn install --production --ignore-scripts --prefer-offline
|
||||
|
||||
# Run nginx + api
|
||||
FROM nginx:stable-alpine as runner
|
||||
|
||||
RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.11/main/ nodejs=12.22.6-r0
|
||||
|
||||
COPY --from=client-builder /app/dist /client
|
||||
|
||||
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
WORKDIR /server
|
||||
|
||||
ENV NODE_ENV "production"
|
||||
|
||||
ENV BASE_PATH "api"
|
||||
|
||||
COPY --from=server-builder /app/dist ./dist
|
||||
COPY --from=server-builder /app/node_modules ./node_modules
|
||||
COPY --from=server-builder /app/package.json ./package.json
|
||||
|
||||
COPY entrypoint.sh .
|
||||
|
||||
CMD [ "./entrypoint.sh" ]
|
@ -0,0 +1,8 @@
|
||||
version: '3.3'
|
||||
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
container_name: dust-mail
|
||||
ports:
|
||||
- 3000:80
|
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
nginx -g "daemon off;" & node dist/main && fg
|
@ -0,0 +1,14 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /client;
|
||||
index index.html;
|
||||
expires 30d;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue