-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Containerize #505
Open
kmehant
wants to merge
7
commits into
codeuino:development
Choose a base branch
from
kmehant:containerize
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Containerize #505
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
55f8026
Add dockerfiles for dev and prod use cases
kmehant 60c948c
Add docker-compose config for dev and prod use case
kmehant baf90ae
Add GitHub Workflow
kmehant a0d40d6
Change repo name to codeuino1
kmehant b2c9003
Add specific version of Node -> 14 ships npm v6
kmehant f67e3cb
Fix docker login in the pipeline
kmehant d35ea7e
Run in interactive mode for the dev server to work
kmehant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.github | ||
.git | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: donut-client-image-ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- development | ||
|
||
tags: | ||
- v* | ||
|
||
env: | ||
IMAGE_NAME: donut-client:latest | ||
REPO_NAME: codeuino1 | ||
REGISTRY_NAME: registry.hub.docker.com | ||
|
||
jobs: | ||
push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build image | ||
run: docker build . --file Dockerfile.prod --tag $IMAGE_NAME | ||
|
||
- name: Log into registry | ||
run: echo "{{ secrets.DOCKER_PASSWORD }}" | docker login -u {{ secrets.DOCKER_USERNAME }} --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=$REGISTRY_NAME/$REPO_NAME/$IMAGE_NAME | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:latest | ||
docker push $IMAGE_ID:$VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM node:14 | ||
|
||
# Copy package.json file into container | ||
COPY package.json package.json | ||
COPY package-lock.json package-lock.json | ||
|
||
# Install node modules | ||
RUN npm install && \ | ||
npm install --only=dev && \ | ||
npm cache clean --force --loglevel=error | ||
|
||
# Volume to mount source code into container | ||
VOLUME [ "/client" ] | ||
|
||
# move to the source code directory | ||
WORKDIR /client | ||
|
||
# Start the client | ||
CMD mv ../node_modules . && npm run-script start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM node:14 as builder | ||
|
||
WORKDIR /server | ||
|
||
RUN git clone https://github.com/codeuino/social-platform-donut-frontend.git | ||
|
||
WORKDIR /server/social-platform-donut-frontend | ||
|
||
RUN npm install && \ | ||
npm cache clean --force --loglevel=error | ||
|
||
RUN npm run-script build | ||
|
||
#------------------------------ Production | ||
FROM nginx:alpine as production | ||
|
||
# copy static files | ||
COPY --from=builder /server/social-platform-donut-frontend/build /usr/share/nginx/html | ||
|
||
# Expose ports | ||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: "3" | ||
services: | ||
client: | ||
container_name: client | ||
restart: always | ||
expose: | ||
- "3000" | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.dev | ||
volumes: | ||
- ./:/client | ||
ports: | ||
- "3000:3000" | ||
stdin_open: true | ||
tty: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: "3" | ||
services: | ||
client: | ||
container_name: client-production | ||
restart: always | ||
expose: | ||
- "80" | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.prod | ||
volumes: | ||
- ./:/client | ||
ports: | ||
- "80:80" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be verbose with npm version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vaibhavdaren
Are you pointing to the tag
--loglevel
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://medium.com/@Quigley_Ja/specifying-npm-version-in-dockerfile-ee6e71a60945
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vaibhavdaren Thanks for the link, I have changed node from LTS to 14 so this will be always using a specific version of npm which is v6 (Major).
However, the link mentions about using a higher version of npm outside the lower node versions. I guess now we have got v14 (three years later) with stringent npm v6 within the container. So. we no need to install again npm as per the link. Does this sound right?