Skip to content

Commit

Permalink
Build in container (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruemmelspalter authored Nov 2, 2021
1 parent fe44b76 commit 62928cd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 27 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules
package-lock.json
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- run: cd frontend && yarn install
- run: cd backend && yarn install
- run: make cleanpush
- run: make push
22 changes: 18 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@ FROM node:lts

WORKDIR /opt/betterschuman

COPY entrypoint.sh .
RUN chmod ug+x entrypoint.sh

COPY backend/package.json .
RUN npm install --production

COPY backend/dist .
COPY frontend/dist ./static
RUN yarn install --production

WORKDIR /tmp/betterschuman

COPY backend ./backend
COPY frontend ./frontend
RUN cd frontend && yarn install && yarn run build
RUN cd backend && yarn install && yarn run build

WORKDIR /opt/betterschuman

RUN cp -r /tmp/betterschuman/backend/dist/* .
RUN cp -r /tmp/betterschuman/frontend/dist static

CMD node main.js
RUN rm -r /tmp/betterschuman
ENTRYPOINT ["/opt/betterschuman/entrypoint.sh"]
21 changes: 2 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@ branchName := $(shell git rev-parse --abbrev-ref HEAD)
tagName := $(shell git describe --tags)


default: cleanbuild


frontend/dist: $(wildcard frontend/src/**)
cd frontend && yarn build

backend/dist: $(wildcard backend/src/**)
cd backend && yarn build

default: build

push: build
docker push kruemmelspalter/betterschuman:$(commitHash)
Expand All @@ -35,14 +27,5 @@ deploy: build
tests: $(wildcard backend/test/**) $(wildcard backend/**)
cd backend && npm run test && npm run test:cov

clean: frontend/dist backend/dist
rm -rv backend/dist frontend/dist

build: backend/dist frontend/dist
build:
docker build . -t kruemmelspalter/betterschuman:$(commitHash)

cleanbuild: build clean

cleanpush: push clean

cleandeploy: deploy clean
3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
cd "$0"/.. || exit
node main.js

0 comments on commit 62928cd

Please sign in to comment.