Skip to content
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

initial dotnet sdk & runtime images #550

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ versioned-images := php-8.1-fpm \
ruby-3.3 \
opensearch-2 \
mysql-8.0 \
mysql-8.4
mysql-8.4 \
dotnet-6-sdk \
dotnet-6-runtime \
dotnet-8-sdk \
dotnet-8-runtime


# default-versioned-images are images that formerly had no versioning, and are made backwards-compatible.
# the below versions are the ones that map to the unversioned namespace
Expand Down Expand Up @@ -322,6 +327,7 @@ build/ruby-3.1 build/ruby-3.2 build/ruby-3.3: build/commons
build/opensearch-2: build/commons
build/mongo-4: build/commons
build/mysql-8.0 build/mysql-8.4: build/commons
build/dotnet-6-sdk build/dotnet-6-runtime build/dotnet-8-sdk build/dotnet-8-runtime: build/commons

#######
####### Building Images
Expand Down
14 changes: 14 additions & 0 deletions helpers/TESTING_base_images_dockercompose.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep ruby-3-1
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep ruby-3-2
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep ruby-3-3
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep dotnet-6
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep dotnet-8

# commons should be running Alpine Linux
docker compose exec -T commons sh -c "cat /etc/os-release" | grep "Alpine Linux"
Expand Down Expand Up @@ -272,6 +274,18 @@ docker compose exec -T ruby-3-3 sh -c "ruby -v" | grep "3.3"

# ruby-3-3 should be serving content
docker compose exec -T commons sh -c "curl ruby-3-3:3000/tmp/" | grep "ruby 3.3"

# dotnet-6 should have .NET 6
docker compose exec -T dotnet-6 sh -c "dotnet --list-sdks" | grep "6.0"

# dotnet-6 should be serving content
docker compose exec -T commons sh -c "curl dotnet-6:3000" | grep "6.0"

# dotnet-8 should have .NET 8
docker compose exec -T dotnet-8 sh -c "dotnet --list-sdks" | grep "8.0"

# dotnet-8 should be serving content
docker compose exec -T commons sh -c "curl dotnet-8:3000" | grep "8.0"
```

Destroy tests
Expand Down
389 changes: 389 additions & 0 deletions helpers/TESTING_dockercompose.md

Large diffs are not rendered by default.

38 changes: 36 additions & 2 deletions helpers/images-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '2.3'

x-user:
&default-user
# The default user under which the containers should run. Change this if you are on linux and run with another user than id `1000`
Expand Down Expand Up @@ -229,3 +227,39 @@ services:
environment:
- LAGOON_TEST_VAR=all-images
<< : *default-user # uses the defined user from top

dotnet-6:
image: uselagoon/dotnet-6-sdk:latest
working_dir: /app
environment:
- ASPNETCORE_URLS=http://+:3000
- DOTNET_USE_POLLING_FILE_WATCHER=1
networks:
- default
labels:
lagoon.type: basic
ports:
- "3000"
command: ["sh", "-c", "
dotnet new web -n myWebApp -o /app --no-https;
dotnet --list-sdks | cut -c1-8 | xargs -I {} sed -i 's/Hello World!/{}/g' /app/Program.cs;
dotnet run /app --no-launch-profile
"]

dotnet-8:
image: uselagoon/dotnet-8-sdk:latest
working_dir: /app
environment:
- ASPNETCORE_URLS=http://+:3000
- DOTNET_USE_POLLING_FILE_WATCHER=1
networks:
- default
labels:
lagoon.type: basic
ports:
- "3000"
command: ["sh", "-c", "
dotnet new web -n myWebApp -o /app --no-https;
dotnet --list-sdks | cut -c1-8 | xargs -I {} sed -i 's/Hello World!/{}/g' /app/Program.cs;
dotnet run /app --no-launch-profile
"]
38 changes: 35 additions & 3 deletions helpers/services-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '2.3'

x-user:
&default-user
# The default user under which the containers should run. Change this if you are on linux and run with another user than id `1000`
Expand Down Expand Up @@ -158,7 +156,7 @@ services:
labels:
lando.type: opensearch
ports:
- "9200" # exposes the port 8080 with a random local port, find it with `docker-compose port nginx 8080`
- "9200"
<< : *default-user # uses the defined user from top

internal-services-test:
Expand All @@ -168,3 +166,37 @@ services:
environment:
- LAGOON_TEST_VAR=all-images
<< : *default-user # uses the defined user from top

dotnet-6:
image: testlagoon/dotnet-6-sdk:pr-550
working_dir: /app
environment:
- ASPNETCORE_URLS=http://+:3000
- DOTNET_USE_POLLING_FILE_WATCHER=1
networks:
- default
labels:
lagoon.type: basic
ports:
- "3000"
command: ["sh", "-c", "
dotnet new web -n myWebApp -o /app --no-https;
dotnet run /app --no-launch-profile
"]

dotnet-7:
image: testlagoon/dotnet-7-sdk:pr-550
working_dir: /app
environment:
- ASPNETCORE_URLS=http://+:3000
- DOTNET_USE_POLLING_FILE_WATCHER=1
networks:
- default
labels:
lagoon.type: basic
ports:
- "3000"
command: ["sh", "-c", "
dotnet new web -n myWebApp -o /app --no-https;
dotnet run /app --no-launch-profile
"]
34 changes: 34 additions & 0 deletions images/dotnet-runtime/6.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons

FROM mcr.microsoft.com/dotnet/runtime:6.0.32-alpine3.20

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

ENV LAGOON=dotnet-6-runtime

# Copy commons files
COPY --from=commons /lagoon /lagoon
COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/wait-for /bin/
COPY --from=commons /sbin/tini /sbin/
COPY --from=commons /home /home

RUN apk add --no-cache bash

RUN fix-permissions /etc/passwd \
&& mkdir -p /home

ENV TMPDIR=/tmp \
TMP=/tmp \
HOME=/home \
# When Bash is invoked via `sh` it behaves like the old Bourne Shell and sources a file that is given in `ENV`
ENV=/home/.bashrc \
# When Bash is invoked as non-interactive (like `bash -c command`) it sources a file that is given in `BASH_ENV`
BASH_ENV=/home/.bashrc

# Make sure shells are not running forever
COPY 80-shell-timeout.sh /lagoon/entrypoints/
RUN echo "source /lagoon/entrypoints/80-shell-timeout.sh" >> /home/.bashrc

ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.sh"]
34 changes: 34 additions & 0 deletions images/dotnet-runtime/7.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons

FROM mcr.microsoft.com/dotnet/runtime:7.0.1-alpine3.17

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

ENV LAGOON=dotnet-6-sdk

# Copy commons files
COPY --from=commons /lagoon /lagoon
COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/wait-for /bin/
COPY --from=commons /sbin/tini /sbin/
COPY --from=commons /home /home

RUN apk add --no-cache bash

RUN fix-permissions /etc/passwd \
&& mkdir -p /home

ENV TMPDIR=/tmp \
TMP=/tmp \
HOME=/home \
# When Bash is invoked via `sh` it behaves like the old Bourne Shell and sources a file that is given in `ENV`
ENV=/home/.bashrc \
# When Bash is invoked as non-interactive (like `bash -c command`) it sources a file that is given in `BASH_ENV`
BASH_ENV=/home/.bashrc

# Make sure shells are not running forever
COPY 80-shell-timeout.sh /lagoon/entrypoints/
RUN echo "source /lagoon/entrypoints/80-shell-timeout.sh" >> /home/.bashrc

ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.sh"]
34 changes: 34 additions & 0 deletions images/dotnet-runtime/8.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons

FROM mcr.microsoft.com/dotnet/runtime:8.0.7-alpine3.20

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

ENV LAGOON=dotnet-8-runtime

# Copy commons files
COPY --from=commons /lagoon /lagoon
COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/wait-for /bin/
COPY --from=commons /sbin/tini /sbin/
COPY --from=commons /home /home

RUN apk add --no-cache bash

RUN fix-permissions /etc/passwd \
&& mkdir -p /home

ENV TMPDIR=/tmp \
TMP=/tmp \
HOME=/home \
# When Bash is invoked via `sh` it behaves like the old Bourne Shell and sources a file that is given in `ENV`
ENV=/home/.bashrc \
# When Bash is invoked as non-interactive (like `bash -c command`) it sources a file that is given in `BASH_ENV`
BASH_ENV=/home/.bashrc

# Make sure shells are not running forever
COPY 80-shell-timeout.sh /lagoon/entrypoints/
RUN echo "source /lagoon/entrypoints/80-shell-timeout.sh" >> /home/.bashrc

ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.sh"]
7 changes: 7 additions & 0 deletions images/dotnet-runtime/80-shell-timeout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# If we are running within kubernetes, set a shell timeout of 10mins.
# We do that so old shells are closed and we can idle the cli container
if [ $KUBERNETES_PORT ]; then
TMOUT=600
fi
34 changes: 34 additions & 0 deletions images/dotnet-sdk/6.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons

FROM mcr.microsoft.com/dotnet/sdk:6.0.424-alpine3.20

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

ENV LAGOON=dotnet-6-sdk

# Copy commons files
COPY --from=commons /lagoon /lagoon
COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/wait-for /bin/
COPY --from=commons /sbin/tini /sbin/
COPY --from=commons /home /home

RUN apk add --no-cache bash

RUN fix-permissions /etc/passwd \
&& mkdir -p /home

ENV TMPDIR=/tmp \
TMP=/tmp \
HOME=/home \
# When Bash is invoked via `sh` it behaves like the old Bourne Shell and sources a file that is given in `ENV`
ENV=/home/.bashrc \
# When Bash is invoked as non-interactive (like `bash -c command`) it sources a file that is given in `BASH_ENV`
BASH_ENV=/home/.bashrc

# Make sure shells are not running forever
COPY 80-shell-timeout.sh /lagoon/entrypoints/
RUN echo "source /lagoon/entrypoints/80-shell-timeout.sh" >> /home/.bashrc

ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.sh"]
34 changes: 34 additions & 0 deletions images/dotnet-sdk/7.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons

FROM mcr.microsoft.com/dotnet/sdk:7.0.101-alpine3.17

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

ENV LAGOON=dotnet-6-sdk

# Copy commons files
COPY --from=commons /lagoon /lagoon
COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/wait-for /bin/
COPY --from=commons /sbin/tini /sbin/
COPY --from=commons /home /home

RUN apk add --no-cache bash

RUN fix-permissions /etc/passwd \
&& mkdir -p /home

ENV TMPDIR=/tmp \
TMP=/tmp \
HOME=/home \
# When Bash is invoked via `sh` it behaves like the old Bourne Shell and sources a file that is given in `ENV`
ENV=/home/.bashrc \
# When Bash is invoked as non-interactive (like `bash -c command`) it sources a file that is given in `BASH_ENV`
BASH_ENV=/home/.bashrc

# Make sure shells are not running forever
COPY 80-shell-timeout.sh /lagoon/entrypoints/
RUN echo "source /lagoon/entrypoints/80-shell-timeout.sh" >> /home/.bashrc

ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.sh"]
34 changes: 34 additions & 0 deletions images/dotnet-sdk/8.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons

FROM mcr.microsoft.com/dotnet/sdk:8.0.303-alpine3.20

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

ENV LAGOON=dotnet-8-sdk

# Copy commons files
COPY --from=commons /lagoon /lagoon
COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/wait-for /bin/
COPY --from=commons /sbin/tini /sbin/
COPY --from=commons /home /home

RUN apk add --no-cache bash

RUN fix-permissions /etc/passwd \
&& mkdir -p /home

ENV TMPDIR=/tmp \
TMP=/tmp \
HOME=/home \
# When Bash is invoked via `sh` it behaves like the old Bourne Shell and sources a file that is given in `ENV`
ENV=/home/.bashrc \
# When Bash is invoked as non-interactive (like `bash -c command`) it sources a file that is given in `BASH_ENV`
BASH_ENV=/home/.bashrc

# Make sure shells are not running forever
COPY 80-shell-timeout.sh /lagoon/entrypoints/
RUN echo "source /lagoon/entrypoints/80-shell-timeout.sh" >> /home/.bashrc

ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.sh"]
7 changes: 7 additions & 0 deletions images/dotnet-sdk/80-shell-timeout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# If we are running within kubernetes, set a shell timeout of 10mins.
# We do that so old shells are closed and we can idle the cli container
if [ $KUBERNETES_PORT ]; then
TMOUT=600
fi