Skip to content

Commit

Permalink
split into two packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoerlitz committed Apr 11, 2024
1 parent 1d352bb commit 26bd4ff
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 16 deletions.
6 changes: 1 addition & 5 deletions .docker/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ server {
gzip_proxied no-cache no-store private expired auth;
gzip_types text/plain text/css application/javascript;

location /api/v1 {
proxy_pass http://localhost:8001;
}

root /opt/frontend;
root /opt;
location / {
try_files $uri $uri/ /index.html;
}
Expand Down
4 changes: 1 addition & 3 deletions .docker/entry.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/sh

nginx

# Run Node
cd /opt/backend && node src/Application.js
cd /opt && node src/Application.js
28 changes: 25 additions & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
build-backend:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -28,5 +28,27 @@ jobs:

- name: Build and push Docker image
run: |
docker build --pull -t ${{ env.REGISTRY }}/${{ github.repository }}:latest .
docker push ${{ env.REGISTRY }}/${{ github.repository }}:latest
docker build --pull -t ${{ env.REGISTRY }}/${{ github.repository }}-backend:latest -f backend.Dockerfile .
docker push ${{ env.REGISTRY }}/${{ github.repository }}-backend:latest
build-frontend:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
run: |
docker build --pull -t ${{ env.REGISTRY }}/${{ github.repository }}-frontend:latest -f frontend.Dockerfile .
docker push ${{ env.REGISTRY }}/${{ github.repository }}-frontend:latest
8 changes: 3 additions & 5 deletions Dockerfile → backend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ WORKDIR /build
COPY package*.json ./
RUN npm install && npm install typescript -g
COPY . .
RUN npm run all:build
RUN npm run backend:build


FROM nginx:alpine
FROM node:alpine

WORKDIR /opt

Expand All @@ -16,9 +16,7 @@ COPY package*.json ./
RUN apk update && apk add --update nodejs npm
RUN npm install --quiet --unsafe-perm --no-progress --no-audit

COPY --from=build /build/_build/ /opt/

COPY .docker/default.conf /etc/nginx/conf.d/default.conf
COPY --from=build /build/_build/backend /opt/

# Init cron
ADD .docker/entry.sh /entry.sh
Expand Down
26 changes: 26 additions & 0 deletions frontend.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:alpine as build

WORKDIR /build
COPY package*.json ./
RUN npm install && npm install typescript -g
COPY . .
RUN npm run frontend:build


FROM nginx:alpine

WORKDIR /opt

COPY package*.json ./

RUN apk update && apk add --update nodejs npm
RUN npm install --quiet --unsafe-perm --no-progress --no-audit

COPY --from=build /build/_build/frontend /opt/

COPY .docker/default.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
STOPSIGNAL SIGQUIT

CMD ["nginx", "-g", "daemon off;"]

0 comments on commit 26bd4ff

Please sign in to comment.