moving project to gitea
This commit is contained in:
54
beetroot/Dockerfile
Normal file
54
beetroot/Dockerfile
Normal file
@@ -0,0 +1,54 @@
|
||||
# Stage 1: Build stage
|
||||
# Using the Golang docker image specifically for Alpine. Necessary because Alpine Linux uses musl instead of glibc, making binaries compiled dynamically using glibc incompatible with Alpine.
|
||||
FROM golang:1.23.9-alpine3.21 AS build
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache git
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Clone the Beetroot repository
|
||||
RUN git clone https://github.com/skandix/Beetroot.git .
|
||||
|
||||
# Change directory so that we can build the program.
|
||||
WORKDIR /app/cmd/beetroot
|
||||
|
||||
# Downloads any Go module dependencies defined in the source code.
|
||||
RUN go get
|
||||
# Build beetroot as a Go binary
|
||||
RUN go build -o beetroot main.go
|
||||
RUN mv beetroot /app
|
||||
|
||||
# Stage 2: Runtime stage
|
||||
FROM alpine:3.21
|
||||
|
||||
# Open the port 8080, so that Beetroot can listen through it.
|
||||
EXPOSE 8080
|
||||
|
||||
# Add support for timezone
|
||||
RUN apk add --no-cache tzdata
|
||||
|
||||
# Install curl for testing
|
||||
RUN apk add --no-cache curl
|
||||
|
||||
# Create a non-root user to run the application, naming it 'beetroot'.
|
||||
RUN adduser -D beetroot
|
||||
|
||||
# Set env variable for timezone
|
||||
ENV TZ=UTC
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the compiled binary from the build stage
|
||||
COPY --from=build /app/beetroot /app/
|
||||
|
||||
# Change ownership to non-root user
|
||||
RUN chown -R beetroot:beetroot /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER beetroot
|
||||
|
||||
# Run beetroot when the container starts
|
||||
CMD ["/app/beetroot"]
|
||||
14
beetroot/compose.yaml
Normal file
14
beetroot/compose.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
services:
|
||||
beetroot:
|
||||
build: .
|
||||
image: registry.internal.uia.no/ikt210-g-25h-skyinfrastruktur/labgroup4/exercise03
|
||||
container_name: beetroot
|
||||
ports:
|
||||
- 8080:8080
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./secret
|
||||
target: /dev/shm/.secret
|
||||
read_only: true
|
||||
env_file:
|
||||
- path: env_variables.env
|
||||
2
beetroot/env_variables.env
Normal file
2
beetroot/env_variables.env
Normal file
@@ -0,0 +1,2 @@
|
||||
TZ=UTC
|
||||
Cyb3r53cur1ty=content of the env variable
|
||||
23
beetroot/run
Executable file
23
beetroot/run
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
### Lokal test
|
||||
#sudo docker build -t beetroot .
|
||||
#sudo docker run beetroot
|
||||
|
||||
### Registry build & upload
|
||||
#docker login registry.internal.uia.no
|
||||
# disconnect eduvpn
|
||||
#docker build -t registry.internal.uia.no/ikt114-g-25v-it-orkestrering/labgroup16/exercise02 .
|
||||
# connect eduvpn
|
||||
#docker push registry.internal.uia.no/ikt114-g-25v-it-orkestrering/labgroup16/exercise02
|
||||
|
||||
### Registry pull & run
|
||||
#docker pull registry.internal.uia.no/ikt114-g-25v-it-orkestrering/labgroup16/exercise02
|
||||
#docker run registry.internal.uia.no/ikt114-g-25v-it-orkestrering/labgroup16/exercise02
|
||||
|
||||
|
||||
|
||||
# Compose
|
||||
docker compose build --push
|
||||
docker compose build && docker compose up
|
||||
1
beetroot/secret
Normal file
1
beetroot/secret
Normal file
@@ -0,0 +1 @@
|
||||
some secret text written in this file....
|
||||
Reference in New Issue
Block a user