Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample Docker config for SPM projects in CLion / AppCode
Index: .dockerignore
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- .dockerignore (date 1538746751000)
+++ .dockerignore (date 1538746751000)
@@ -0,0 +1,1 @@
+.build/*/*.*
\ No newline at end of file
Index: Dockerfile
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- Dockerfile (date 1538751938000)
+++ Dockerfile (date 1538751938000)
@@ -0,0 +1,45 @@
+FROM swift:4.1
+
+WORKDIR /package
+
+COPY . ./
+# We can replace this port with what the user wants
+EXPOSE 8080
+EXPOSE 22
+
+# Default user if not provided
+ARG bx_dev_user=root
+ARG bx_dev_userid=1000
+
+# Install system level packages
+RUN apt-get update && apt-get upgrade -y
+
+RUN apt-get install -y apt-utils sudo
+
+RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libpq-dev openssh-server && \
+ apt-get clean && \
+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+
+# Add utils files
+ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-docker/master/utils/run-utils.sh /swift-utils/run-utils.sh
+ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-docker/master/utils/common-utils.sh /swift-utils/common-utils.sh
+RUN chmod -R 555 /swift-utils
+
+# Create user if not root
+RUN if [ $bx_dev_user != "root" ]; then useradd -ms /bin/bash -u $bx_dev_userid $bx_dev_user; fi
+
+RUN mkdir /var/run/sshd
+RUN echo 'root:screencast' | chpasswd
+RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
+
+# SSH login fix. Otherwise user is kicked off after login
+RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
+ENV NOTVISIBLE "in users profile"
+RUN echo "export VISIBLE=now" >> /etc/profile
+
+# Bundle application source & binaries
+CMD service ssh restart &&\
+ cd /package &&\
+ rm -rf .build &&\
+ swift build &&\
+ ./.build/x86_64-unknown-linux/debug/Kitura-Sample
\ No newline at end of file
Index: .idea/runConfigurations/Docker.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- .idea/runConfigurations/Docker.xml (date 1538747752000)
+++ .idea/runConfigurations/Docker.xml (date 1538747752000)
@@ -0,0 +1,32 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="Docker" type="docker-deploy" factoryName="dockerfile" singleton="true" server-name="Docker">
+ <deployment type="dockerfile">
+ <settings>
+ <option name="JSONFilePath" value="" />
+ <option name="buildCliOptions" value="" />
+ <option name="command" value="" />
+ <option name="containerName" value="kitura" />
+ <option name="entrypoint" value="" />
+ <option name="imageTag" value="kitura" />
+ <option name="portBindings">
+ <list>
+ <DockerPortBindingImpl>
+ <option name="containerPort" value="8080" />
+ <option name="hostPort" value="8080" />
+ </DockerPortBindingImpl>
+ <DockerPortBindingImpl>
+ <option name="containerPort" value="22" />
+ <option name="hostPort" value="49155" />
+ </DockerPortBindingImpl>
+ </list>
+ </option>
+ <option name="commandLineOptions" value="" />
+ <option name="sourceFilePath" value="Dockerfile" />
+ <option name="startBrowserSettings">
+ <browser url="http://127.0.0.1" />
+ </option>
+ </settings>
+ </deployment>
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment