Skip to content

Commit da18a0e

Browse files
committed
Dockerize CRA
Signed-off-by: NishkarshRaj <[email protected]>
1 parent a28bd74 commit da18a0e

File tree

2 files changed

+12
-99
lines changed

2 files changed

+12
-99
lines changed

Dockerfile

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/3_actions.md

Lines changed: 12 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -16,82 +16,23 @@ The build and testing of the software is automated and every change or iteration
1616

1717
![Actions](img/actions.png)
1818

19-
### A template GitHub Action
19+
### A template GitHub Action - Create React App
2020

21-
* Declarative Actions YML script
22-
23-
```yml
24-
name: Docker
25-
26-
on:
27-
push
28-
env:
29-
IMAGE_NAME: helloworld
30-
31-
jobs:
32-
push:
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@v2
36-
37-
- name: Build image
38-
run: docker build . --file Dockerfile --tag $IMAGE_NAME
39-
40-
- name: Log into registry
41-
run: echo "${{ secrets.GH_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
42-
43-
- name: Push image
44-
run: |
45-
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
46-
47-
# Change all uppercase to lowercase
48-
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
49-
50-
# Strip git ref prefix from version
51-
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
52-
53-
# Strip "v" prefix from tag name
54-
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
55-
56-
# Use Docker `latest` tag convention
57-
[ "$VERSION" == "master" ] && VERSION=latest
58-
59-
echo IMAGE_ID=$IMAGE_ID
60-
echo VERSION=$VERSION
61-
62-
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
63-
docker push $IMAGE_ID:$VERSION
64-
```
65-
66-
* Dockerfile
21+
* `Dockerfile`
6722

6823
```dockerfile
69-
# Base Image
70-
FROM ubuntu
71-
72-
# Commands to be executed on Image Creation
73-
RUN apt-get -y upgrade && apt-get -y update
74-
75-
# Install Python
76-
RUN apt install -y python3
77-
RUN python3 --version
78-
79-
# Install Java
80-
RUN apt install -y openjdk-11-jre-headless
81-
RUN java --version
82-
83-
# Install C++ Compiler
84-
RUN apt install -y g++
85-
RUN g++ --version
24+
FROM node:14-alpine
25+
WORKDIR /usr/src/app
26+
COPY . .
27+
RUN npm install
28+
EXPOSE 3000
29+
CMD [ "npm", "start" ]
30+
```
8631

87-
# Install Docker
88-
RUN apt install -y docker.io
89-
RUN docker --version
32+
- `.dockerignore`
9033

91-
# Move GitHub source files to Docker Image
92-
RUN mkdir /src
93-
ADD src/ /src
94-
WORKDIR /src
34+
```
35+
node_modules/
9536
```
9637

9738
## Important Links and References
@@ -104,8 +45,6 @@ WORKDIR /src
10445

10546
[GitHub Actions Blog](https://iq.opengenus.org/github-actions-using-container-scripts/)
10647

107-
[Learn GitHub Actions](https://lab.github.com/githubtraining/github-actions:-hello-world)
108-
10948
[Actions Checkout Repository](https://github.com/actions/checkout)
11049

11150
[GitHub Marketplace](https://github.com/marketplace)

0 commit comments

Comments
 (0)