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 image #550

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ versioned-images := php-8.0-fpm \
varnish-7-persistent-drupal \
ruby-3.0 \
ruby-3.1 \
opensearch-2
opensearch-2 \
dotnet-6-sdk \
dotnet-6-runtime \
dotnet-7-sdk \
dotnet-7-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 @@ -315,6 +320,7 @@ build/mariadb-10.6-drupal: build/mariadb-10.6
build/ruby-3.0 build/ruby-3.1: build/commons
build/opensearch-2: build/commons
build/mongo-4: build/commons
build/dotnet-6-sdk build/dotnet-6-runtime build/dotnet-7-sdk build/dotnet-7-runtime: build/commons

#######
####### Building Images
Expand Down
18 changes: 16 additions & 2 deletions helpers/TESTING_dockercompose.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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 all-images_solr-8_1
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep all-images_varnish-6_1
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep all-images_varnish-7_1
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep all-images_dotnet-6_1
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep all-images_dotnet-7_1

# commons should be running Alpine Linux
docker-compose exec -T commons sh -c "cat /etc/os-release" | grep "Alpine Linux"
Expand Down Expand Up @@ -309,12 +311,12 @@ docker-compose exec -T commons sh -c "curl python-3-10:3000/tmp/test" | grep "Py
# python-3-11 should be version 3.11
docker-compose exec -T python-3-11 sh -c "python -V" | grep "3.11"

# python-3-10 should have basic tools installed
# python-3-11 should have basic tools installed
docker-compose exec -T python-3-11 sh -c "pip list --no-cache-dir" | grep "pip"
docker-compose exec -T python-3-11 sh -c "pip list --no-cache-dir" | grep "setuptools"
docker-compose exec -T python-3-11 sh -c "pip list --no-cache-dir" | grep "virtualenv"

# python-3-10 should be serving content
# python-3-11 should be serving content
docker-compose exec -T commons sh -c "curl python-3-11:3000/tmp/test" | grep "Python 3.11"

# node-14 should have Node 14
Expand Down Expand Up @@ -362,6 +364,18 @@ docker-compose exec -T commons sh -c "curl elasticsearch-7:9200" | grep number |

# elasticsearch-7 should be healthy
docker-compose exec -T commons sh -c "curl elasticsearch-7:9200/_cluster/health" | json_pp | grep status | grep green

# dotnet-6 should have Dotnet 6.0
docker-compose exec -T dotnet-6 sh -c "dotnet --version" | grep "6.0"

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

# dotnet-7 should have Dotnet 7.0
docker-compose exec -T dotnet-7 sh -c "dotnet --version" | grep "7.0"

# dotnet-7 should be serving content
docker-compose exec -T commons sh -c "curl dotnet-7:3000" | grep "Hello World!"
```

Destroy tests
Expand Down
38 changes: 36 additions & 2 deletions helpers/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,15 @@ 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

elasticsearch-7:
image: uselagoon/elasticsearch-7:latest
labels:
lando.type: elasticsearch
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 @@ -250,3 +250,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.12-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/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"]
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.404-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/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"]
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