1
0
Fork 0
This commit is contained in:
Vili Sinervä 2023-03-17 12:43:43 +02:00
parent 1a5357e1df
commit e98d78b444
16 changed files with 109 additions and 8 deletions

View file

@ -1,8 +0,0 @@
FROM node:16.19
EXPOSE 8080
WORKDIR /usr/src/app
COPY package*.json ./
COPY . .
RUN npm install && npm run build
RUN npm install -g serve
CMD ["serve", "-s", "-l", "8080", "build"]

View file

@ -0,0 +1 @@
https://github.com/ArcticCoder/github-actions-exercise

View file

@ -0,0 +1 @@
https://github.com/ArcticCoder/docker-cloud-deploy-exercise

5
Part3/Exercise03/builder.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
git clone https://github.com/$1.git ./repo
cd ./repo
docker build . -t $2
docker push $2

View file

@ -0,0 +1,5 @@
FROM docker:23.0.1-cli
WORKDIR /usr/src/app
COPY ./builder.sh ./builder.sh
RUN apk add git
ENTRYPOINT ["/usr/src/app/builder.sh"]

6
Part3/Exercise04/builder.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
git clone https://github.com/$1.git ./repo
cd ./repo
docker build . -t $2
docker login -u $DOCKER_USER -p $DOCKER_PWD
docker push $2

View file

@ -0,0 +1,9 @@
FROM golang:1.16
EXPOSE 8080
WORKDIR /usr/src/app
COPY . .
ENV REQUEST_ORIGIN=http://devops:5000
RUN go build
RUN useradd -m appuser
USER appuser
CMD ["./server"]

View file

@ -0,0 +1,11 @@
FROM node:16.19
EXPOSE 5000
WORKDIR /usr/src/app
COPY package*.json ./
COPY . .
ENV REACT_APP_BACKEND_URL=http://devops:8080
RUN npm install && npm run build
RUN npm install -g serve
RUN useradd -m appuser
USER appuser
CMD ["serve", "-s", "-l", "5000", "build"]

View file

@ -0,0 +1,9 @@
Before:
Front - 1.26GB
Back - 1.07GB
After:
Front - 1.26GB
Back - 1.07GB
No visible difference at this scale.

View file

@ -0,0 +1,7 @@
Before:
Front - 1.26GB
Back - 1.07GB
After:
Front - 463MB
Back - 447MB

View file

@ -0,0 +1,15 @@
FROM node:16.19-alpine3.16 as build-stage
WORKDIR /usr/src/app
COPY package*.json ./
COPY . .
ENV REACT_APP_BACKEND_URL=http://devops:8080
RUN npm install && npm run build
FROM node:16.19-alpine3.16
EXPOSE 5000
WORKDIR /usr/src/app
COPY --from=build-stage /usr/src/app/build /usr/src/app/build
RUN npm install -g serve && \
adduser -D appuser
USER appuser
CMD ["serve", "-s", "-l", "5000", "build"]

View file

@ -0,0 +1,5 @@
Before:
Front - 463MB
After:
Front - 127MB

View file

@ -0,0 +1,12 @@
FROM golang:1.16.15-alpine3.15 as build-stage
WORKDIR /usr/src/app
COPY . .
RUN adduser -D appuser && CGO_ENABLED=0 go build
FROM scratch
EXPOSE 8080
ENV REQUEST_ORIGIN=http://devops:5000
COPY --from=build-stage /usr/src/app/server /
COPY --from=build-stage /etc/passwd /etc/passwd
USER appuser
CMD ["/server"]

View file

@ -0,0 +1,5 @@
Before:
Back - 447MB
After:
Back - 18MB

View file

@ -0,0 +1,16 @@
# Using the -slim images instead of alpine, because the alpine images threw error:
# library initialization failed - unable to allocate file descriptor table - out of memory
# and I didn't want to submit something that required modifying Docker settings
FROM openjdk:8-jdk-slim as build
WORKDIR /usr/src/app
COPY pom.xml ./
COPY . .
RUN ./mvnw package
FROM openjdk:8-jre-slim
EXPOSE 8080
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/target/docker-example-1.1.3.jar .
RUN useradd -m appuser
USER appuser
CMD ["java", "-jar", "./docker-example-1.1.3.jar"]

View file

@ -0,0 +1,2 @@
Before: 435MB
After: 213MB