Skip to content

Commit

Permalink
Multistage dockerfiles (#484)
Browse files Browse the repository at this point in the history
* update nginx docker image to 1.24.0

* update python deps

* update client side package-lock.json deps with npm update

* fix tsc build error

* add build section to client service in compose file

* reuse server image for celery containers (instead of building the same image 3 times just to run different commands)

* add docs on containerization strategy and use consistent dev target naming in Dockerfiles

* add test target to client Dockerfile

* add docker config files to CI/CD labeler
  • Loading branch information
dpgraham4401 authored May 20, 2023
1 parent 834c5cf commit c12d794
Show file tree
Hide file tree
Showing 17 changed files with 2,221 additions and 1,748 deletions.
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ reactjs:
- client/**/*

CI/CD:
- .github/workflows/**.yaml
- any: ['.github/workflows/**.yaml', '**/*Dockerfile', '**/*.dockerignore']

documentation:
- any: ['docs/**/*', 'docs/haztrak_book/**/*', '**/README.md']
Expand Down
3 changes: 2 additions & 1 deletion .idea/runConfigurations/Compose_Dev.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions client/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
.dockerignore
README.md
node_modules/
**/*.spec.tsx
**/*.spec.ts
**/.vscode
**/.idea
**/*.bak
10 changes: 3 additions & 7 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
.env

# dependencies
/node_modules
/.pnp
.pnp.js
/build

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
tsconfig.tsbuildinfo
19 changes: 15 additions & 4 deletions client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@ COPY . .
RUN npm ci --silent
RUN npm run build

# Bundle stage
FROM nginx:1.21.0-alpine as production

# test
FROM builder as test
WORKDIR /app
CMD ["npm", "run", "test"]

# local development
FROM builder as dev
WORKDIR /app
EXPOSE 3000
CMD ["npm", "start"]

# Production
FROM nginx:1.24.0-alpine as production
WORKDIR /app
ENV NODE_ENV production
# copy build from builder stage
COPY --from=builder /app/build /usr/share/nginx/html
# Add nginx.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
# Start nginx
CMD ["nginx", "-g", "daemon off;"]
Loading

0 comments on commit c12d794

Please sign in to comment.