Skip to content

Docker Deployment with Openshift Templates and package updates #148

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockeringnore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!package.json
!public
!src
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM ubuntu:22.04 as builder

USER root
RUN apt-get update && apt-get upgrade -y
RUN apt-get -y --no-install-recommends install ca-certificates wget
RUN update-ca-certificates
RUN wget -qO- https://deb.nodesource.com/setup_16.x | bash
RUN apt-get install -y nodejs
RUN npm install -g npm

WORKDIR /app

# Installs required node packages
COPY . .
RUN npm install && npm run build

# ==== Final Image
FROM ubuntu:22.04 AS final

ENV DEBIAN_FRONTEND=noninteractive

USER root

RUN groupadd --gid 1001 node \
&& useradd --uid 1001 --gid node --shell /bin/bash --create-home node \
&& set -ex \
&& apt-get update && apt-get upgrade -y \
&& apt-get -y --no-install-recommends install \
ca-certificates wget \
&& update-ca-certificates \
&& wget -qO- https://deb.nodesource.com/setup_16.x | bash \
&& apt-get install -y nodejs \
&& npm install -g npm \
&& apt-get -y remove wget \
&& apt-get -y --purge autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g serve

USER node:node
WORKDIR /app

# Copying build output
COPY --from=builder --chown=node:node /app/build/ build

EXPOSE 3000
CMD ["serve", "-s", "-d", "-p", "3000", "--cors", "build"]
16 changes: 16 additions & 0 deletions openshift/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Getting Started

You will need to clone the this repo and checkout the docker branch. Then modify the resources in the openshift directory with your project namespace, and modify the route with your clusters domain. When building the docker image tag it with your container registry that is used by openshift.

```
git clone https://github.com/mjj203/fresco-docker.git
cd fresco-docker
git checkout docker
docker login $registry
docker build -t $registry/fresco:latest -f Dockerfile .
docker push $registry/fresco:latest
oc login
oc apply -f openshift/deployment-fresco.yaml
oc apply -f openshift/service-fresco.yaml
oc apply -f openshift/route-fresco.yaml
```
21 changes: 21 additions & 0 deletions openshift/deployment-fresco.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: fresco
namespace: $namespace
spec:
replicas: 1
selector:
matchLabels:
app: fresco
template:
metadata:
labels:
app: fresco
spec:
containers:
- name: fresco
image: '$registry/fresco:latest'
ports:
- containerPort: 3000
protocol: TCP
17 changes: 17 additions & 0 deletions openshift/route-fresco.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: fresco
namespace: $namespace
spec:
host: fresco-$namespace.apps.$domain
to:
kind: Service
name: fresco
weight: 100
port:
targetPort: 3000
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None
12 changes: 12 additions & 0 deletions openshift/service-fresco.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: Service
apiVersion: v1
metadata:
name: fresco
namespace: $namespace
spec:
ports:
- protocol: TCP
port: 3000
targetPort: 3000
selector:
app: fresco
Loading