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

Can it be deployed directly? #27

Closed
VineFiner opened this issue Nov 22, 2020 · 2 comments
Closed

Can it be deployed directly? #27

VineFiner opened this issue Nov 22, 2020 · 2 comments

Comments

@VineFiner
Copy link

If there is no additional development, can it be deployed directly?

dockerFile

# ================================
# Build image
# ================================
FROM swift:5.3-xenial as build

# Install OS updates and, if needed, sqlite3
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
    && apt-get -q update \
    && apt-get -q dist-upgrade -y \
    && apt-get install -y libsqlite3-dev \
    && apt-get install -y zip \
    && rm -rf /var/lib/apt/lists/*

# Set up a build area
WORKDIR /build

# First just resolve dependencies.
# This creates a cached layer that can be reused
# as long as your Package.swift/Package.resolved
# files do not change.
COPY ./Package.* ./
RUN swift package resolve

# Copy entire repo into container
COPY . .

# Build everything, with optimizations and test discovery
RUN swift build --enable-test-discovery -c release

# Switch to the staging area
WORKDIR /staging

# Uncomment the next line if you need to load resources from the `Public` directory.
# Ensure that by default, neither the directory nor any of its contents are writable.
# 
RUN mv /build/Public ./Public && chmod -R a-w ./Public

# Copy main executable to staging area
# We copy all needed Swift runtime libraries into this folder as well.
# We do this by checking which libraries are needed at runtime with the ldd command and copy only those that have swift in the name.
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/Run" ./ \
    && ldd ./Run | grep swift | awk '{print $3}' | xargs cp -Lv -t ./ \
    && ln -s "Run" "bootstrap" \
    && zip --symlinks lambda.zip *

shell

#!/bin/sh

# Build image
docker build -t vapor_one . -f Dockerfile.build
docker create --name extract vapor_one
docker cp extract:/staging ./app
docker rm -f extract
@tib
Copy link
Member

tib commented Nov 22, 2020

I'm actively developing this project, haven't updated the Dockerfile yet to reflect the new changes.

Will do that in a later release, or if you want feel free to submit a PR. Thank you. 👍

@tib
Copy link
Member

tib commented Jan 5, 2021

This issue was resolved via the #41 PR.

@tib tib closed this as completed Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants